CodeForces

来源:互联网 发布:linux退出 编辑:程序博客网 时间:2024/05/18 22:50

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 ai”, or “Suspect number ai didn’t commit the crime”. Also, the suspect could say so about himself (ai = 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?

Input
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 “+ai” (without the quotes), if the suspect number i says that the crime was committed by suspect number ai, or “-ai” (without the quotes), if the suspect number i says that the suspect number ai didn’t commit the crime (ai is an integer, 1 ≤ ai ≤ n).

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

Output
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.

Example
Input
1 1
+1
Output
Truth
Input
3 2
-1
-2
-3
Output
Not defined
Not defined
Not defined
Input
4 1
+2
-3
+4
-1
Output
Lie
Not defined
Lie
Not defined
Note
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.

首先判断每个人是逃犯的情况符不符合m个人说实话
然后判断合适的情况有多少
判断一个人是不是逃犯只要判断他被人说是逃犯和不说他是逃犯的人和等于m就可以了,因为如果他是逃犯那么这些人都没说谎。
然后通过可能发生的的事情的数量判断每个人说没说谎
如果一个人说另一个人是逃犯而这个人不可能是逃犯那么就是说谎
如果一个人说另一个人是逃犯而这个人确实可能是逃犯那么这个人说的话就不被确定
如果一个人说另一个人是逃犯而可能的事实只有一种那么他却说的就是实话而这个人是对的
如果一个人说其他人不是逃犯而这个人可能是逃犯那么他说的话就是不确定的
如果一个人说另一个人不是逃犯而这个人不可能是逃犯那么他说的就是对的
如果一个人说另一个人不是逃犯而这个人可能是逃犯并且事实唯一那么他就说了谎那么个人确实是逃犯

#include<iostream>#include<string>#include<algorithm>using namespace std;int tu[100001], ky[100001], bky[100001], dui[100001],zgky=0,zgbky=0;int main(){    int n, m;    cin >> n >> m;    for (int a = 1; a <= n; a++)    {        scanf("%d", &tu[a]);        if (tu[a] < 0)bky[-tu[a]]++,zgbky++;        else ky[tu[a]]++, zgky++;    }    int kn = 0;    for (int a = 1; a <= n; a++)    {        if (ky[a] + zgbky - bky[a] == m)        {            kn++;            dui[a] = 1;        }    }    for (int a = 1; a <= n; a++)    {        if (tu[a] > 0)        {            if (!dui[tu[a]])printf("Lie\n");            else if (kn > 1)printf("Not defined\n");            else printf("Truth\n");        }        else        {            if(!dui[-tu[a]])printf("Truth\n");            else if (kn > 1)printf("Not defined\n");            else printf("Lie\n");        }    }}
0 0