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:

  1. 5
  2. -2
  3. +3
  4. -4
  5. +5
  6. +4

Sample Output 1:

  1. 1 4

Sample Input 2:

  1. 6
  2. +6
  3. +3
  4. +1
  5. -5
  6. -2
  7. +4

Sample Output 2 (the solution is not unique):

  1. 1 5

Sample Input 3:

  1. 5
  2. -2
  3. -3
  4. -4
  5. -5
  6. -1

Sample Output 3:

  1. No Solution
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. int main(){
  6. int n;
  7. cin >> n;
  8. vector<int> v(n+);
  9. for(int i=;i <= n;i++)cin >> v[i];
  10. for(int i=;i <= n;i++){
  11. for(int j=i+;j <= n;j++){
  12. vector<int> lie,a(n+,);
  13. a[i] = a[j] = -;
  14. for(int k=;k <=n ;k++){
  15. if(v[k]*a[abs(v[k])]<)lie.push_back(k);
  16. }
  17.  
  18. if(lie.size() == &&a[lie[]]+a[lie[]] == ){
  19. cout << i << " " << j;
  20. return ;
  21. }
  22. }
  23. }
  24. cout << "No Solution";
  25.  
  26. return ;
  27. }

窝自闭了,自己写了200+行,看题解30行,以后写超过40min的题果断放弃,90%可能性是思路不对

  1.  

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. Django session/cookie

    一.cookie  常用方法: 获取:  需要在消息体设置值 1:设置cookie def login(request): if request.method == "POST": ...

  2. 命令行创建cocos2d-x的工程

    1. 命令行创建cocos lua工程cocos new MyGame -p com.your_company.mygame -l lua2. 进入工程目录, 编译运行时库cocos compile ...

  3. MariaDB与MySQL

    一.MariaDB安装部署 tar zxvf mariadb-5.5.31-linux-x86_64.tar.gz mv mariadb-5.5.31-linux-x86_64 /usr/local/ ...

  4. 【js】了解前端缓存,收获不止于此!

    了解前端缓存,收获不止于此! 这次我们来讲一下关于前端缓存的问题.感谢赵欢同学提供doc素材. 首先,开局我画了一张图,你会对文章有一个大局了解. 今天讲的是前端缓存. 前端缓存有3大种:如图,分为H ...

  5. 利用python抓取页面数据

    1.首先是安装python(注意python3.X和python2.X是不兼容的,我们最好用python3.X) 安装方法:安装python 2.安装成功后,再进行我们需要的插件安装.(这里我们需要用 ...

  6. EDK II之SMM/SMI

    SMM:System Managerment Mode SMM有自己的smm core以及dispatcher(可以简单的把smm core跟dxe core看成是平行的存在),smm有自己的运行空间 ...

  7. docker和kubernetes中hostname的使用和常见问题

    hostname在docker中是使用UTS namespace进行隔离的.docker中主要有两种ns的用法, 一种是docker run --uts="" busybox.这种 ...

  8. android源码编译出现No private recovery resources for TARGET_DEVICE解决方法

    mmm或mm出现以下提示的解决方法:Terminal log:No private recovery resources for TARGET_DEVICE xxxxxxmake: Entering ...

  9. MySql 8.0 C#连接报错 MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host '12.118.224.181' for user 'root' using method 'caching_sha2_password' failed with message: Reading from t

    解决方法 在连接字符串后面加上   SslMode=None 

  10. 深度学习网络中numpy多维数组的说明

    目前在计算机视觉中应用的数组维度最多有四维,可以表示为 (Batch_size, Row, Column, Channel) 以下将要从二维数组到四维数组进行代码的简单说明: Tips: 1) 在nu ...