题目链接:1148 Werewolf - Simple Version (20 point(s))

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 liars. Can you point out the werewolves?

Now you are asked to solve a harder version of this problem: given that there were N players, with 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liars. You are supposed to point out the werewolves.

Input Specification

Each input file contains one test case. For each case, the first line gives a positive integer N (5≤N≤100). 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 ascending order the indices of the two 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 smallest 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 smaller than B. In case there is no solution, simply print No Solution.

Sample Case

Sample Input 1
5
-2
+3
-4
+5
+4
Sample Output 1
1 4
Sample Input 2
6
+6
+3
+1
-5
-2
+4
Sample Output 2 (the solution is not unique)
1 5
Sample Input 3
5
-2
-3
-4
-5
-1
Sample Output 3
No Solution

分析

PAT(A) 1148 Werewolf - Simple Version(Java)逻辑推理的更多相关文章

  1. PAT 1148 Werewolf - Simple Version

    1148 Werewolf - Simple Version (20 分)   Werewolf(狼人杀) is a game in which the players are partitioned ...

  2. PAT 1148 Werewolf - Simple Version [难理解]

    1148 Werewolf - Simple Version (20 分) Werewolf(狼人杀) is a game in which the players are partitioned i ...

  3. 1148 Werewolf - Simple Version (20 分)

    Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...

  4. 1148 Werewolf - Simple Version

    Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...

  5. PAT_A1148#Werewolf - Simple Version

    Source: PAT 1148 Werewolf - Simple Version (20 分) Description: Werewolf(狼人杀) is a game in which the ...

  6. PAT A1148 Werewolf - Simple Version (20 分)——暴力遍历,负负得正

    Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...

  7. PAT(B) 1021 个位数统计(Java)

    题目链接:1021 个位数统计 (15 point(s)) 代码 /** * Score 15 * Run Time 93ms * @author wowpH * @version 1.0 */ im ...

  8. PAT(B) 1019 数字黑洞(Java)

    题目链接:1019 数字黑洞 (20 point(s)) 分析 输入正整数n后,将n转成int型数组nArr[4] 用Arrays.sort(int[] a)方法将数组nArr非递减排序 很显然,非递 ...

  9. PAT 乙级 1042.字符统计 C++/Java

    题目来源 请编写程序,找出一段给定文字中出现最频繁的那个英文字母. 输入格式: 输入在一行中给出一个长度不超过 1000 的字符串.字符串由 ASCII 码表中任意可见字符及空格组成,至少包含 1 个 ...

随机推荐

  1. JS中注入eval, Function等系统函数截获动态代码

    正文 现在很多网站都上了各种前端反爬手段,无论手段如何,最重要的是要把包含反爬手段的前端javascript代码加密隐藏起来,然后在运行时实时解密动态执行. 动态执行js代码无非两种方法,即eval和 ...

  2. lol英雄时刻

    2019.5.30 翻出了当年人生中第一次LOL五杀截图...我用佐伊拿五杀了! 第一次五杀超激动的

  3. Windows平台上运行Tomcat

    从之前的学习中知道,可以调用Bootstrap类将Toomcat作为一个独立的应用程序来运行,在Windows平台上,可以调用startup.bat批处理文件来启动Tomcat,或运行shutdown ...

  4. mysql innodb与myisam存储文件的区别

    myisam: .frm: 存储表定义 .myd(MYData):存储数据 .MYI(MYindex):存储引擎 innodb: .frm:存储表定义 .idb:存储数据和索引,在同一个文件中

  5. Android页面切换

    参考地址: http://www.crifan.com/android_how_to_create_new_ui_and_switch_to_another_new_ui/ 想要实现,在Android ...

  6. 分析imx8mm-evk评估板的pinctrl设备树

    1. 分析arch/arm64/boot/dts/freescale/imx8mm-evk.dts中的i2c3相关的pinctrl_i2c3节点 pinctrl_i2c3: i2c3grp { fsl ...

  7. AndoridSQLite数据库开发基础教程(6)

    AndoridSQLite数据库开发基础教程(6) 为数据库添加添加空表 如果开发者想要往数据库中添加表和列,操作步骤如下: (1)在打开的数据库中,单击左下方的“+”按钮,弹出Table Edito ...

  8. Dart接口

    /* 和Java一样,dart也有接口,但是和Java还是有区别的. 首先,dart的接口没有interface关键字定义接口,而是普通类或抽象类都可以作为接口被实现. 同样使用implements关 ...

  9. Qt编写气体安全管理系统9-数据查询

    一.前言 数据查询模块在整个系统中难度最低,由于Qt对数据库操作的封装堪称完美,所以各种查询都是手到擒来,不费吹灰之力.Qt中内置了sqlite数据库,你可以在数据库插件目录sqldrivers发现q ...

  10. Hive开启mapjoin优化、并行执行、动态分区

    1. mapjoin优化适合小表join大表 set hive.optimize.skewjoin=true; //有数据倾斜时开启负载均衡,默认false set hive.auto.convert ...