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. x509证书相关内容

    什么是证书 X.509证书,其核心是根据RFC 5280编码或数字签名的数字文档.    实际上,术语X.509证书通常指的是IETF的PKIX证书和X.509 v3证书标准的CRL 文件,即如RFC ...

  2. 【.NET】 C# 时间戳和DataTime 互相转换

    1.C# DateTime转换为Unix时间戳 System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(, , )); // ...

  3. 介绍Kubernetes监控Heapster

    什么是Heapster? Heapster是容器集群监控和性能分析工具,天然的支持Kubernetes和CoreOS,Kubernetes有个出名的监控agent—cAdvisor.在每个kubern ...

  4. 安卓抓包https

    https://blog.csdn.net/yichengace/article/details/80167878

  5. ElasticSearch(十一)Elasticsearch清空指定Index/Type数据

    POST /index_name/type_name/_delete_by_query?conflicts=proceed { "query": { "match_all ...

  6. linux之添加切换用户、系统变量、selinux、防火墙、系统中文乱码的讲解

    ######linux用户分类1.root 用户 linux皇帝 2.普通用户 贫民百姓 [root@oldboyedu-01 oldboy]# useradd oldboy[root@oldboye ...

  7. 复旦大学2018--2019学年第一学期高等代数I期末考试情况分析

    一.期末考试成绩90分以上的同学(共21人) 周烁星(99).封清(99).叶雨阳(97).周子翔(96).王捷翔(96).张思哲(95).丁思成(94).陈宇杰(94).谢永乐(93).张哲维(93 ...

  8. Android系统应用Mms之Sms短信发送流程(Mms应用部分)二

    1. 新建一条短信, 在发送短信之前, 首先创建的是一个会话Conversation, 以后所有与该接收人(一个或多个接收人)的消息交互, 都在该会话Conversation中. ComposeMes ...

  9. Bigger-Mai 养成计划,Python基础巩固二

    模块初识1.标准库2.第三方库import sys sys.path #自己的本文件名不可为sys.py#输出模块存储的环境变量sys.argv #打印脚本的相对路径sys.argv[2] #取第二个 ...

  10. Pandas数据处理+Matplotlib绘图案例

    利用pandas对数据进行预处理然后再使用matplotlib对处理后的数据进行数据可视化是数据分析中常用的方法. 第一组例子(星巴克咖啡店) 假如我们现在有这样一组数据:星巴克在全球的咖啡店信息,如 ...