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<Msuch 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 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

//来自liu chuo大佬的答案
#include<iostream>
#include<vector>
using namespace std;
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 ;
}

1148 Werewolf - Simple Version (20 分)的更多相关文章

  1. PAT 1148 Werewolf - Simple Version

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

  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 1148 Werewolf - Simple Version [难理解]

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

  4. 1148 Werewolf - Simple Version

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

  5. PAT_A1148#Werewolf - Simple Version

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

  6. PAT A1148 Werewolf - Simple Version (20 分)——暴力遍历,负负得正

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

  7. PTA 07-图5 Saving James Bond - Hard Version (30分)

    07-图5 Saving James Bond - Hard Version   (30分) This time let us consider the situation in the movie ...

  8. PAT 甲级 1041 Be Unique (20 分)

    1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...

  9. PAT 甲级 1011 World Cup Betting (20)(20 分)

    1011 World Cup Betting (20)(20 分)提问 With the 2010 FIFA World Cup running, football fans the world ov ...

随机推荐

  1. MAC通过SSH使用PEM文件登录

    1.命令如下 ssh -i key.pem ssh -i key.pem root@IP 如果出现报错说明这个问题是文件的权限太大了,需要给小点 sudo chmod 600 key.pem 然后再执 ...

  2. weblogic参数说明

    公司有个项目,部署在weblogic8.1上之后,发现比在tomcat下慢很多,经过分析排查,原因是web应用的WEB-INF下的weblogic.xml里的参数设置不合理(使用默认值有时并非最佳值) ...

  3. Docker ubuntu镜像更换apt-get源

    在Dockerfile中添加 RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list RUN ap ...

  4. scrapy设置代理

    在爬取网站内容的时候,最常遇到的问题是:网站对IP有限制,会有防抓取功能,最好的办法就是IP轮换抓取(加代理) 下面来说一下Scrapy如何配置代理,进行抓取 1.在Scrapy工程下新建“middl ...

  5. easyui-tabs 页签绑定click事件,动态加载jqgrid

    .前台代码 <%-- builed by manage.aspx.cmt [ver:] at // :: --%> <%@ Page Language="C#" ...

  6. ESP8266文档阅读ESP8266 SDK 入门指南

    ESP8266 SDK  入门指南 1.概述 1.2.ESP8266 HDK 1.3.ESP8266 SDK 1.4.ESP8266 FW 1.5.ESP8266 工具集 2.1.开发板方案 3.软件 ...

  7. jQuery提供的存储接口

    jQuery.data( element, key, value ) //静态接口,存数据jQuery.data( element, key ) //静态接口,取数据 .data( key, valu ...

  8. bootstrap导航菜单

    <!DOCTYPE html><html lang="zh-cn"><head><meta charset="utf-8&quo ...

  9. (转)用事实说话,成熟的ORM性能不是瓶颈,灵活性不是问题:EF5.0、PDF.NET5.0、Dapper原理分析与测试手记

    原文地址:http://www.cnblogs.com/bluedoctor/p/3378683.html [本文篇幅较长,可以通过目录查看您感兴趣的内容,或者下载格式良好的PDF版本文件查看] 目录 ...

  10. 安装两个XAMPP或者更新XAMPP时, PHP版本还是旧版本的问题

    转载自 : http://blog.csdn.net/everything1209/article/details/53466725 原文 : 问题:我电脑有原先有一个wamp,但是PHP版本为5.5 ...