1148 Werewolf - Simple Version (20 分)
 

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的更多相关文章

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

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

  2. PAT(A) 1148 Werewolf - Simple Version(Java)逻辑推理

    题目链接:1148 Werewolf - Simple Version (20 point(s)) Description Werewolf(狼人杀) is a game in which the p ...

  3. PAT A1148 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 (20 分)

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

  5. 1148 Werewolf - Simple Version

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

  6. PAT_A1148#Werewolf - Simple Version

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

  7. [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 ...

  8. PAT T1022 Werewolf

    暴力搜索加剪枝~ #include<bits/stdc++.h> using namespace std; ; int a[maxn]; bool visit[maxn]; vector& ...

  9. PAT (Advanced Level) Practice(更新中)

    Source: PAT (Advanced Level) Practice Reference: [1]胡凡,曾磊.算法笔记[M].机械工业出版社.2016.7 Outline: 基础数据结构: 线性 ...

随机推荐

  1. 【javascript】随机颜色

    调用该方法则会返回一个#xxx的rgb随机颜色 function color1(){ var sum=""; var shuzu2=['a','b','c','d','e','f' ...

  2. MVC 纯Table实现树节点效果+授权

    这几夜心里颇不平静, 奈何 JS水平有限,前台效果耗时四天,后台传值一天,直至昨夜丑时测试初步完成,其实就是一个给tree来授权,网上开源的插件很多,如treeview.treejs.easyui 等 ...

  3. github一些事

    我的个人github地址是:https://github.com/BUGDuYu 我们开发团队小组的github地址是: https://github.com/APPdoctrine 资源推荐: gi ...

  4. LeetCode 链表(旋转链表61)

    /* * 给定一个链表,旋转链表,将链表每个节点向右移动 k 个位置,其中 k 是非负数. * 构造一个环,对链表进行处理. * *实现原理:先遍历一遍,得出链表长度,注意K可能大于len,之后令k% ...

  5. Eclipse中tomcat启动时报jar包 it's not a class错误;

    Console报错如上: 解决方法: 在Eclipse中Servers文件夹下 对应的项目文件中catalina.properties文件中tomcat.util.scan.DefaultJarSca ...

  6. JS中常见设计模式总结

    github: https://github.com/14glwu/FEInterviewBox/tree/master/JS%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F ...

  7. nginx 配置反向代理

    之前的前端是8123端口,使用此端口让nginx的反向代理. vim /etc/nginx/conf.d/80-fr.conf upstream cats{ server 127.0.0.1:8123 ...

  8. Mybatis学习之一

    mybatis是目前市面上最流行的ORM框架之一,作为JavaEE程序员,在工作中不可能不用到mybatis.所以为了工作,为了学习,为了个人的发展,每个JavaEE程序员都要学习,学会mybatis ...

  9. 清除控制台 console

    清除控制台 console.log(1) // console.clear() // CTRL + K // Ctrl + L // process.stdout.write('\033c'); // ...

  10. CentOS7攻克日记(三) —— 安装Python3.6

    我是在EVERNOTE上面写的,本来格式是有代码段的,结果复制上来就没有了,所以会有一点乱,我就不调整了   我主要安装的是python环境,这一篇主要解决一下python的问题.在这里给个建议,安装 ...