CodeForces 156B Suspects(枚举)

B. Suspects

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 aididn'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 isays 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 ilied for sure and print "Not defined" if he could lie and could tell the truth, too, depending on who committed the crime.

Examples

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
枚举i是罪犯,然后看哪些人说了真话,人数等于m说明这个人可能是罪犯#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;
#define MAX 100000
int n,m;
int a[MAX+5];
int b[MAX+5];
int f[MAX+5];
int tag[MAX+5];
int main()
{
    scanf("%d%d",&n,&m);
    int x;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&f[i]);
        if(f[i]>0)
        {
            a[f[i]]++;
        }
        else
        {
            b[-f[i]]++;
            sum++;
        }
    }
    memset(tag,0,sizeof(tag));
    int k=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]+sum-b[i]==m)
        {
            tag[i]=1;
            k++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(f[i]>0)
        {
            if(tag[f[i]]&&k==1)
                printf("Truth\n");
            else if(!tag[f[i]])
                printf("Lie\n");
            else
                printf("Not defined\n");
        }
        else
        {
            if(!tag[-f[i]])
                printf("Truth\n");
            else if(tag[-f[i]]&&k==1)
                printf("Lie\n");
            else
                printf("Not defined\n");
        }
    }
    return 0;
}

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏菩提树下的杨过

As3.0中的位图(Bitmap/BitmapData)编程

As3.0中的位图(Bitmap/BitmapData)编程功能十分丰富,下面这些是官方文档上的基本示例: 1.位图使用(模糊)滤镜 //创建一个矩形区域的Bi...

40360
来自专栏更流畅、简洁的软件开发方式

[自定义服务器控件] 第三步:CheckBoxList。

前面发了文本框和下拉列表框的,这回发一个CheckBoxList。不知道中文名字该叫什么。 CheckBoxList 最郁闷的地方就是:明明可以选择多个选项,但...

23260
来自专栏一个会写诗的程序员的博客

禅与 JavaScript 编程艺术, Zen and The Art of JavaScript Programming禅与 JavaScript 编程艺术

Zen and The Art of JavaScript Programming

12610
来自专栏闵开慧

曾经做过的40道程序设计课后习题总结(四)

曾经做过的40道程序设计课后习题总结(四) 课后习题目录 1 斐波那契数列 2 判断素数 3 水仙花数 4 分解质因数 5 杨辉三角 6 学习成绩查询...

48890
来自专栏GIS讲堂

js实现城市首字母导航

12010
来自专栏草根专栏

Typescript 查缺补漏

Types Casting: let input = xxx as HTMLInputElement; let input = <HTMLElement>xxx...

22830
来自专栏数据结构与算法

P2580 于是他错误的点名开始了

题目背景 XS中学化学竞赛组教练是一个酷爱炉石的人。 他会一边搓炉石一边点名以至于有一天他连续点到了某个同学两次,然后正好被路过的校长发现了然后就是一顿欧拉欧拉...

31770
来自专栏高爽的专栏

POI读取Excel常见问题

       最近在做一个将excel导入到报表中的功能,使用了POI来实现,发现POI使用有诸多不便之处,先记录下来,以后可能考虑使用Openxml。    ...

27800
来自专栏听雨堂

加点的心得

加点的一般方法:    Catalog _catalog=MapInfo.Engine.Session.Current.Catalog;    MapInf...

197100
来自专栏算法修养

CodeForces 651 C Watchmen

C. Watchmen time limit per test 3 seconds memory limit per test 256 megaby...

27430

扫码关注云+社区

领取腾讯云代金券