ConundrumReloaded
SRM 625 · 2013-12-22 · by vexorian
Problem Statement
- 'L' if person i said that person (i+1) is a liar,
- 'H' if person i said that person (i+1) is a honest person,
- '?' if you didn't ask person i.
You are given the
Constraints
- answers will contain between 2 and 50 characters, inclusive.
- Each character in answers will be 'L', 'H' or '?'.
"LLH" Returns: 1
According to the input: Person 0 says that person 1 is a liar. Person 1 says that person 2 is a liar. Person 2 says that person 0 is a honest person. Clearly, they cannot all be honest, so there is at least one liar. It is possible that person 1 is liar and the other two are honest. Hence, the smallest possible number of liars is one. (Note that it is also possible that person 1 is honest and the other two are liars.)
"?????" Returns: 0
Nobody told us anything. It is possible that everybody is honest.
"LHLH?" Returns: 2
If person #1 and person #2 are liars, then the answers would be "LHLHH". This is consistent with the answers we received.
"??LLLLLL??" Returns: 3
"LLL" Returns: -1
Each of the 8 possible combinations of (liar / honest person) will lead to a contradiction.
"?HL" Returns: 1
A case in which changing "?" to "H" is not a good result.
Submissions are judged against all 296 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ConundrumReloaded with a public method int minimumLiars(string answers) · 296 test cases · 2 s / 256 MB per case