PAT(A) 1148 Werewolf - Simple Version(Java)逻辑推理
题目链接: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)逻辑推理的更多相关文章
- PAT 1148 Werewolf - Simple Version
1148 Werewolf - Simple Version (20 分) Werewolf(狼人杀) is a game in which the players are partitioned ...
- PAT 1148 Werewolf - Simple Version [难理解]
1148 Werewolf - Simple Version (20 分) Werewolf(狼人杀) is a game in which the players are partitioned i ...
- 1148 Werewolf - Simple Version (20 分)
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...
- 1148 Werewolf - Simple Version
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...
- PAT_A1148#Werewolf - Simple Version
Source: PAT 1148 Werewolf - Simple Version (20 分) Description: Werewolf(狼人杀) is a game in which the ...
- PAT A1148 Werewolf - Simple Version (20 分)——暴力遍历,负负得正
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...
- PAT(B) 1021 个位数统计(Java)
题目链接:1021 个位数统计 (15 point(s)) 代码 /** * Score 15 * Run Time 93ms * @author wowpH * @version 1.0 */ im ...
- PAT(B) 1019 数字黑洞(Java)
题目链接:1019 数字黑洞 (20 point(s)) 分析 输入正整数n后,将n转成int型数组nArr[4] 用Arrays.sort(int[] a)方法将数组nArr非递减排序 很显然,非递 ...
- PAT 乙级 1042.字符统计 C++/Java
题目来源 请编写程序,找出一段给定文字中出现最频繁的那个英文字母. 输入格式: 输入在一行中给出一个长度不超过 1000 的字符串.字符串由 ASCII 码表中任意可见字符及空格组成,至少包含 1 个 ...
随机推荐
- 软件工程实践2019第五次作业——结对编程的编程实现 version1.1
1.链接 我的博客链接https://github.com/S031402112 结对同学的博客https://www.cnblogs.com/jiabingge/ 我们队创建的仓库的Github项目 ...
- Mono Features of cheat engine
If you attach to a process/game that uses mono, you should see a new "Mono" menu item on t ...
- 谈谈你对This对象的理解?
1.this总是指向函数的直接调用者(而非间接调用者):2.如果有new关键字,this指向new出来的那个对象:3.在事件中,this指向触发这个事件的对象,特殊的是,IE中的attachEvent ...
- 借助中间件优化代码 将请求RequestId在服务端接收到请求在处理业务逻辑之前生成
将请求RequestId在服务端接收到请求在处理业务逻辑之前生成
- python try except 出现异常时,except 中如何返回异常的信息字符串
https://docs.python.org/3/tutorial/errors.html#handling-exceptions https://docs.python.org/3/library ...
- android strings: %s、%1$s、%d、%1$d占位符
实际开发的过程中我们有时候会遇到,一个TextView里面会遇到会有一个一大串固定的文字,而里面的数字或者个别字需要根据后台的接口而展示的.这个时候我们最简单的方法就是在string.xml文件里 使 ...
- Web 性能压力测试工具之 Siege 详解
Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力.可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行.s ...
- 贪心:leetcode 870. Advantage Shuffle、134. Gas Station、452. Minimum Number of Arrows to Burst Balloons、316. Remove Duplicate Letters
870. Advantage Shuffle 思路:A数组的最大值大于B的最大值,就拿这个A跟B比较:如果不大于,就拿最小值跟B比较 A可以改变顺序,但B的顺序不能改变,只能通过容器来获得由大到小的顺 ...
- vs 设置护眼背景颜色
工具 —> 选项 —> 环境 —> 字体和颜色 —> 纯文本(显示项中) —> 项目背景 —> 自定义—> 色调位85.饱和度123.亮度205,保存即可.测 ...
- ISO/IEC 9899:2011 条款6.6——常量表达式
6.6 常量表达式 语法 1.constant-expression conditional-expression 描述 2.一个常量表达式可以在翻译期间被计算,而不是在运行时,并且根据情况可以被用于 ...
1148 Werewolf - Simple Version (20 分) Werewolf(狼人杀) is a game in which the players are partitioned ...
1148 Werewolf - Simple Version (20 分) Werewolf(狼人杀) is a game in which the players are partitioned i ...
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...
Source: PAT 1148 Werewolf - Simple Version (20 分) Description: Werewolf(狼人杀) is a game in which the ...
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...
题目链接:1021 个位数统计 (15 point(s)) 代码 /** * Score 15 * Run Time 93ms * @author wowpH * @version 1.0 */ im ...
题目链接:1019 数字黑洞 (20 point(s)) 分析 输入正整数n后,将n转成int型数组nArr[4] 用Arrays.sort(int[] a)方法将数组nArr非递减排序 很显然,非递 ...
题目来源 请编写程序,找出一段给定文字中出现最频繁的那个英文字母. 输入格式: 输入在一行中给出一个长度不超过 1000 的字符串.字符串由 ASCII 码表中任意可见字符及空格组成,至少包含 1 个 ...
1.链接 我的博客链接https://github.com/S031402112 结对同学的博客https://www.cnblogs.com/jiabingge/ 我们队创建的仓库的Github项目 ...
If you attach to a process/game that uses mono, you should see a new "Mono" menu item on t ...
1.this总是指向函数的直接调用者(而非间接调用者):2.如果有new关键字,this指向new出来的那个对象:3.在事件中,this指向触发这个事件的对象,特殊的是,IE中的attachEvent ...
将请求RequestId在服务端接收到请求在处理业务逻辑之前生成
https://docs.python.org/3/tutorial/errors.html#handling-exceptions https://docs.python.org/3/library ...
实际开发的过程中我们有时候会遇到,一个TextView里面会遇到会有一个一大串固定的文字,而里面的数字或者个别字需要根据后台的接口而展示的.这个时候我们最简单的方法就是在string.xml文件里 使 ...
Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力.可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行.s ...
870. Advantage Shuffle 思路:A数组的最大值大于B的最大值,就拿这个A跟B比较:如果不大于,就拿最小值跟B比较 A可以改变顺序,但B的顺序不能改变,只能通过容器来获得由大到小的顺 ...
工具 —> 选项 —> 环境 —> 字体和颜色 —> 纯文本(显示项中) —> 项目背景 —> 自定义—> 色调位85.饱和度123.亮度205,保存即可.测 ...
6.6 常量表达式 语法 1.constant-expression conditional-expression 描述 2.一个常量表达式可以在翻译期间被计算,而不是在运行时,并且根据情况可以被用于 ...