PTA Werewolf
Description:
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,
player #1 said: “Player #2 is a werewolf.”;
player #2 said: “Player #3 is a human.”;
player #3 said: “Player #4 is a werewolf.”;
player #4 said: “Player #5 is a human.”; and
player #5 said: “Player #4 is a human.”.
Given that there were 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liers. Can you point out the werewolves?
Now you are asked to solve a harder vertion of this problem: given that there were N players, with M werewolves among them, at least one but not all the werewolves were lying, and there were exactly L liers. You are supposed to point out the werewolves.
Input Specification:
Each input file contains one test case. For each case, the first line gives three positive integer N (5 ≤ N ≤ 100), M and L (2 ≤ M,L < N). Then N lines follow and the i-th line gives the statement of the i-th player (1 ≤ i ≤ N), which is represented by the index of the player with a positive sign for a human and a negative sign for a werewolf.
Output Specification:
If a solution exists, print in a line in descending order the indices of the M werewolves. The numbers must be separated by exactly one space with no extra spaces at the beginning or the end of the line. If there are more than one solution, you must output the largest solution sequence – that is, for two sequences A = { a[1], …, a[M] } and B = { b[1], …, b[M] }, if there exists 0 ≤ k < M such that a[i] = b[i] (i ≤ k) and a[k+1]>b[k+1], then A is said to be larger than B. In case there is no solution, simply print No Solution.
Sample Input 1:
5 2 2
-2
+3
-4
+5
+4
Sample Output 1:
4 1
Sample Input 2:
6 2 3
-2
+3
-4
+5
+4
-3
Sample Output 2:
6 4
Sample Input 3:
6 2 5
-2
+3
-4
+5
+4
+6

博客探讨了狼人杀游戏中的逻辑问题,提供了一个更复杂版本的挑战:确定N名玩家中有M名狼人,并且有L个说谎者的情况下的狼人身份。文章描述了输入和输出规格,并提出了解决思路,包括生成可能的狼人组合,验证说谎人数,确保只有狼人在说谎,最后给出代码实现。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



