codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

156B.md (2918B)


      1 Source: https://codeforces.com/problemset/problem/156/B
      2 
      3 B. Suspects
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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*).
     22 
     23 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?
     24 
     25 Input
     26 
     27 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*).
     28 
     29 It is guaranteed that at least one suspect exists, such that if he committed the crime, then exactly *m* people told the truth.
     30 
     31 Output
     32 
     33 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.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 1 1  
     41 +1
     42 ```
     43 
     44 Output
     45 
     46 ```
     47 Truth
     48 ```
     49 
     50 Input
     51 
     52 ```
     53 3 2  
     54 -1  
     55 -2  
     56 -3
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 Not defined  
     63 Not defined  
     64 Not defined
     65 ```
     66 
     67 Input
     68 
     69 ```
     70 4 1  
     71 +2  
     72 -3  
     73 +4  
     74 -1
     75 ```
     76 
     77 Output
     78 
     79 ```
     80 Lie  
     81 Not defined  
     82 Lie  
     83 Not defined
     84 ```
     85 
     86 Note
     87 
     88 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.
     89 
     90 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.
     91 
     92 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.