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 个 ...
随机推荐
- 利用ssh 删除远程服务器文件
ssh 登录,利用命令 rm 登录ssh ssh name@10.202.9.11 rm 命令删除文件 rm file rm -rf 删除文件夹 rm -rf fold 删除当前文件夹内容,保留当前文 ...
- NoSql数据库Redis系列(3)——Redis数据持久化(RDB)
大家都知道 Redis 是一个内存数据库,所谓内存数据库,就是将数据库中的内容保存在内存中,这与传统的MySQL,Oracle等关系型数据库直接将内容保存到硬盘中相比,内存数据库的读写效率比传统数据库 ...
- 第1课_Java基础知识【学习笔记】
摘要:韦东山android视频学习笔记 一.android系统的基本框架如图一所示,应用程序是用java编写的,底层驱动是用C代码写的,java与C怎么连接在一起主要是通过本地服务.android系统 ...
- Flink 之 Data Source
Data Sources 是什么呢?就字面意思其实就可以知道:数据来源. Flink 做为一款流式计算框架,它可用来做批处理,即处理静态的数据集.历史的数据集: 也可以用来做流处理,即实时的处理些实时 ...
- 数据库中的同义词synonym
一.Oracle数据只有一个实例(简单理解就是Oracle 只能建立一个数据库,不像MySQL,它下面可以创建N个库),那么Oracle是根据用户灵活去管理的:这点读起来.理解 起来也不那么难 ...
- web常用服务架构
架构风格就是一种项目的设计模式.常见的架构风格有基于客户端与服务端的.基于组件模型的(EJB).分层架构(MVC).面向服务架构(SOA)等. 一.单体架构 单体架构也称为单体系统或单体应用,就是一种 ...
- mysql起容器的最精简命令
亲测有效的 mysql 容器命令: #pull mysql:5.6 docker pull mysql:5.6 #起容器,映射3306端口,配置root用户密码 docker run -di --na ...
- redis最大连接数
Well, it's a bit late for this post, but since I just spent a lot of time(the whole night) to config ...
- OpenBLAS编译 Debug x64 Win10 vs2015
OpenBLAS编译 Debug x64 Win10 vs2015 >------ 已启动生成: 项目: ZERO_CHECK, 配置: Debug x64 ------ > Che ...
- Tomcat 目录结构以及相关规范的介绍
目录 安装tomcat tomcat目录结构 tomcat/bin目录 tomcat/conf目录 tomcat/logs目录 JavaEE对项目结构的规范 war包 安装Tomcat 参考:安装Ja ...
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 个 ...
ssh 登录,利用命令 rm 登录ssh ssh name@10.202.9.11 rm 命令删除文件 rm file rm -rf 删除文件夹 rm -rf fold 删除当前文件夹内容,保留当前文 ...
大家都知道 Redis 是一个内存数据库,所谓内存数据库,就是将数据库中的内容保存在内存中,这与传统的MySQL,Oracle等关系型数据库直接将内容保存到硬盘中相比,内存数据库的读写效率比传统数据库 ...
摘要:韦东山android视频学习笔记 一.android系统的基本框架如图一所示,应用程序是用java编写的,底层驱动是用C代码写的,java与C怎么连接在一起主要是通过本地服务.android系统 ...
Data Sources 是什么呢?就字面意思其实就可以知道:数据来源. Flink 做为一款流式计算框架,它可用来做批处理,即处理静态的数据集.历史的数据集: 也可以用来做流处理,即实时的处理些实时 ...
一.Oracle数据只有一个实例(简单理解就是Oracle 只能建立一个数据库,不像MySQL,它下面可以创建N个库),那么Oracle是根据用户灵活去管理的:这点读起来.理解 起来也不那么难 ...
架构风格就是一种项目的设计模式.常见的架构风格有基于客户端与服务端的.基于组件模型的(EJB).分层架构(MVC).面向服务架构(SOA)等. 一.单体架构 单体架构也称为单体系统或单体应用,就是一种 ...
亲测有效的 mysql 容器命令: #pull mysql:5.6 docker pull mysql:5.6 #起容器,映射3306端口,配置root用户密码 docker run -di --na ...
Well, it's a bit late for this post, but since I just spent a lot of time(the whole night) to config ...
OpenBLAS编译 Debug x64 Win10 vs2015 >------ 已启动生成: 项目: ZERO_CHECK, 配置: Debug x64 ------ > Che ...
目录 安装tomcat tomcat目录结构 tomcat/bin目录 tomcat/conf目录 tomcat/logs目录 JavaEE对项目结构的规范 war包 安装Tomcat 参考:安装Ja ...