[POJ] [1417] True Liars

Problem Description

Loading...

Problem Analysis

During the Chinese New Year I was also driven crazy by this problem
and had no internet so I couldn’t search for editorials
so at the time I was pretty much falling apart

But it seems the place where I got stuck wasn’t really within the scope of Union-Find
Still, this problem is quite easy to connect with Union-Find

Tell n statements and specify that there are x wizards and y demons
Given xi yi YES/NO
to represent whether xi says yi is a wizard
Finally, if it is possible to determine which ones are wizards
then output these people and append end to finish the output
otherwise output no

We can make a table based on the sample input

1Y2Y 1N2N——
1Y3N 1N3Y——1Y-2Y-3N 1N-2N-3Y
4Y5Y 4N5N——1Y-2Y-3N 1N-2N-3Y
5Y6Y 5N6N——1Y-2Y-3N 1N-2N-3Y 4Y-5Y-6Y 4N-5N-6N
6Y7N 6N7Y——1Y-2Y-3N 1N-2N-3Y 4Y-5Y-6Y-7N 4N-5N-6N-7Y

Based on the Food Chain problem, it is easy to think of merging all the possibilities corresponding to the statements and then searching through them

However… figuring out exactly which people are the Y ones satisfying the conditions is a bit tough, and there is also my lack of confidence in my English plus the logic of the problem statement; you can ask yourself
so at the time I thought…

If a person says he is not a good person, then is he actually a good person?
If he says he is not a good person, then if his statement is true he is a bad person, so his statement should be false; if it is false, then he should be a good person, and his statement is true again.

So I also didn’t find a specific description of this aspect in the problem, so I didn’t figure out how to write this problem specifically.

Then I searched for editorials, and felt I should just put this problem aside for now
I’ll come back to fill it in a few days later; this is also to commemorate my problem-solving experience during the Chinese New Year

Problem link: POJ 1417 True Liars

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...