CF156B.Suspects

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked each one: "Which one committed the crime?". Suspect number i answered either "The crime was committed by suspect number a__i", or "Suspect number a__i didn't commit the crime". Also, the suspect could say so about himself (a__i = i).

Sherlock Holmes understood for sure that exactly m answers were the truth and all other answers were a lie. Now help him understand this: which suspect lied and which one told the truth?

夏洛克·福尔摩斯在调查一起犯罪案件时,锁定了 $ n $ 名嫌疑人。他确信其中恰好有一人实施了该犯罪行为。为了查明真凶,侦探将这些嫌疑人排成一列,并从 $ 1 $ 到 $ n $ 编号。随后,他依次询问每人:“谁犯下了这起罪行?” 第 $ i $ 号嫌疑人回答的内容为以下两种之一:“犯罪者是第 $ a_i $ 号嫌疑人”,或“第 $ a_i $ 号嫌疑人没有犯罪”。此外,嫌疑人也可能指控自己(即 $ a_i = i $)。

福尔摩斯确信,所有回答中恰好有 $ m $ 条为真,其余均为假。现在,请你帮助他判断:每位嫌疑人说的是真话还是谎话?

输入格式

The first line contains two integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ n) — the total number of suspects and the number of suspects who told the truth. Next n lines contain the suspects' answers. The i-th line contains either "+a__i" (without the quotes), if the suspect number i says that the crime was committed by suspect number a__i, or "-a__i" (without the quotes), if the suspect number i says that the suspect number a__i didn't commit the crime (a__i is an integer, 1 ≤ a__i ≤ n).

It is guaranteed that at least one suspect exists, such that if he committed the crime, then exactly m people told the truth.

第一行包含两个整数 nn 和 mm(1≤n≤1051 \leq n \leq 10^5,0≤m≤n0 \leq m \leq n)—— 分别表示嫌疑人的总数以及说真话的嫌疑人人数。接下来的 nn 行包含各嫌疑人的陈述。第 ii 行的内容为:若嫌疑人 ii 声称犯罪者是嫌疑人 aia_i,则该行为 "+aia_i"(不含引号);若嫌疑人 ii 声称嫌疑人 aia_i 没有犯罪,则该行为 "-aia_i"(不含引号)(其中 aia_i 是一个整数,满足 1≤ai≤n1 \leq a_i \leq n)。

题目保证至少存在一个嫌疑人,使得若他实施了犯罪,则恰好有 mm 人说了真话。

输出格式

Print n lines. Line number i should contain "Truth" if suspect number i has told the truth for sure. Print "Lie" if the suspect number i lied for sure and print "Not defined" if he could lie and could tell the truth, too, depending on who committed the crime.

输出 n 行。第 i 行应包含:“Truth”(若嫌疑犯 i 必然说了真话);“Lie”(若嫌疑犯 i 必然说了谎);或 “Not defined”(若根据谁是罪犯的不同,嫌疑犯 i 既可能说谎,也可能说真话)。

输入输出样例

  • 输入#1

    1 1
    +1

    输出#1

    Truth
  • 输入#2

    3 2
    -1
    -2
    -3

    输出#2

    Not defined
    Not defined
    Not defined
  • 输入#3

    4 1
    +2
    -3
    +4
    -1

    输出#3

    Lie
    Not defined
    Lie
    Not defined

说明/提示

The first sample has the single person and he confesses to the crime, and Sherlock Holmes knows that one person is telling the truth. That means that this person is telling the truth.

In the second sample there are three suspects and each one denies his guilt. Sherlock Holmes knows that only two of them are telling the truth. Any one of them can be the criminal, so we don't know for any of them, whether this person is telling the truth or not.

In the third sample the second and the fourth suspect defend the first and the third one. But only one is telling the truth, thus, the first or the third one is the criminal. Both of them can be criminals, so the second and the fourth one can either be lying or telling the truth. The first and the third one are lying for sure as they are blaming the second and the fourth one.

第一个样例中只有一人,且他承认自己犯罪,而夏洛克·福尔摩斯知道恰好有一个人在说真话。这意味着此人说的是真话。

第二个样例中有三名嫌疑人,每人皆否认自己有罪。夏洛克·福尔摩斯知道其中恰好有两人在说真话。任何一人都可能是罪犯,因此我们无法确定其中任一人是否在说真话。

第三个样例中,第二名和第四名嫌疑人分别为第一名和第三名嫌疑人辩护。但仅有一人在说真话,因此第一名或第三名嫌疑人是罪犯。这两人均有可能是罪犯,故第二名和第四名嫌疑人可能在说谎,也可能在说真话。而第一名和第三名嫌疑人则必定在说谎,因为他们指责了第二名和第四名嫌疑人。

输入解题思路,AI测评打分。不知道怎么写?

首页