前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CodeForces 156B Suspects(枚举)

CodeForces 156B Suspects(枚举)

作者头像
ShenduCC
发布2018-04-26 17:25:42
5760
发布2018-04-26 17:25:42
举报
文章被收录于专栏:算法修养算法修养

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

代码语言:javascript
复制
1 1
+1

output

代码语言:javascript
复制
Truth

input

代码语言:javascript
复制
3 2
-1
-2
-3

output

代码语言:javascript
复制
Not defined
Not defined
Not defined

input

代码语言:javascript
复制
4 1
+2
-3
+4
-1

output

代码语言:javascript
复制
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;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-05-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档