PAT 1148 Werewolf - Simple Version
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). Then N lines follow and the i-th line gives the statement of the i-th player (1), 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 [ and [, if there exists 0 such that [ (i≤k) and [, then A is said to be smaller than B. In case there is no solution, simply print No Solution
.
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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; int main(){
int n;
cin >> n;
vector<int> v(n+);
for(int i=;i <= n;i++)cin >> v[i];
for(int i=;i <= n;i++){
for(int j=i+;j <= n;j++){
vector<int> lie,a(n+,);
a[i] = a[j] = -;
for(int k=;k <=n ;k++){
if(v[k]*a[abs(v[k])]<)lie.push_back(k);
} if(lie.size() == &&a[lie[]]+a[lie[]] == ){
cout << i << " " << j;
return ;
}
}
}
cout << "No Solution"; return ;
}
窝自闭了,自己写了200+行,看题解30行,以后写超过40min的题果断放弃,90%可能性是思路不对
PAT 1148 Werewolf - Simple Version的更多相关文章
- PAT 1148 Werewolf - Simple Version [难理解]
1148 Werewolf - Simple Version (20 分) Werewolf(狼人杀) is a game in which the players are partitioned i ...
- PAT(A) 1148 Werewolf - Simple Version(Java)逻辑推理
题目链接:1148 Werewolf - Simple Version (20 point(s)) Description Werewolf(狼人杀) is a game in which the p ...
- PAT A1148 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 (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 ...
- [Functional Programming] Write a simple version of Maybe
Maybe has two types: Just / Nothing. Just() will just return the value that passed in. Nothing retur ...
- PAT T1022 Werewolf
暴力搜索加剪枝~ #include<bits/stdc++.h> using namespace std; ; int a[maxn]; bool visit[maxn]; vector& ...
- PAT (Advanced Level) Practice(更新中)
Source: PAT (Advanced Level) Practice Reference: [1]胡凡,曾磊.算法笔记[M].机械工业出版社.2016.7 Outline: 基础数据结构: 线性 ...
随机推荐
- echarts起始角度
series : [ { type: 'pie', startAngle: 180,// minAngle:5,// radius : ['0','60%'], center: ['50%', '50 ...
- delphi 判断端口(Port)是否被占用(转载)
function IsPortUsed(aPort: Integer): Boolean; var _vSock: TSocket; _vWSAData: TWSAData; _vAddrIn: TS ...
- pom的maven仓库的配置
这里简单记录一下问题 本人配置了nexus的私人仓库,配置阿里云的远程仓库(http://182.92.29.40/nexus/content/groups/public/)和正规的2个库(http: ...
- ABP入门系列之2——ABP模板项目
进入官网下载模板项目 依次按下图选择: 输入验证码开始下载 下载提示: 二.启动项目 使用VS2017打开项目,还原Nuget包: 设置以Web结尾的项目,设置为启动项目: 打开Web.config, ...
- 浅析贝叶斯神经网络(Based on Variational Bayesian)
https://blog.csdn.net/qq_20195745/article/details/82453589 贝叶斯神经网络简介 对于一个神经网络来说,最为核心的是如何根据训练集的数据,得到各 ...
- telnet客户端操作memcached增删改查
一,通过telnet连接进入memcached(telnet 本地ip/服务器ip 端口) 进入后回车看效果: 二, 添加数据和取出数据 添加命令: add key名 0(固定) ...
- nginx cookie 会话保持功能
sticky 会话保持,基于自定义cookie 进行会话保持的方式 安装包下载地址:https://github.com/bymaximus/nginx-sticky-module-ng ./conf ...
- Linux 管理环境变量的文件分为系统级和用户级别
Linux 管理环境变量的文件分为系统级和用户级别 管理环境变量的文件也分为系统级和用户级别: 1.系统级:/etc/profile:该文件是用户登录时,操作系统定制用户环境时使用的第一个文件,应用于 ...
- Hadoop2-HDFS学习笔记之入门(不含YARN及MR的调度功能)
架构 Hadoop整体由HDFS.YARN.MapReduce三大部分组成,推荐架构参考:https://www.cnblogs.com/zhjh256/p/10573684.html. 注:2.x的 ...
- Mac上超好用的计时器和秒表
秒表 https://joaomoreno.github.io/thyme/ 计时器 https://github.com/michaelvillar/timer-app 更新---这个更棒!有网页有 ...