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. svn基础了解

    Apache Subversion 通常被缩写成 SVN,是一个开放源代码的版本控制系统 Subversion(SVN) 是一个开源的版本控制系統, 也就是说 Subversion 管理着随时间改变的 ...

  2. ThinkAdmin for PHP后台管理系统

    ThinkAdmin for PHP后台管理系统 ThinkAdmin 是一个基于 Thinkphp 5.1.x 开发的后台管理系统,集成后台系统常用功能.基于 ThinkPHP 5.1 基础开发平台 ...

  3. [转载]URI、 URL 和 URN 的区别

    1. URI URI = Universal Resource Identifier 统一资源标志符 URI采用一种特定语法标识一个资源的字符串.所标识的资源可能是服务器上的一个文件.不过,也可能是一 ...

  4. 韩顺平Linux学习笔记

    第 一 章    Linux开山篇 1.1 Linux课程的内容介绍 1.2Linux的学习方向 1.2.1. Linux运维工程师:主要做大公司中的电脑系统维护,保证服务器的正常运行,如服务器的优化 ...

  5. 为什么越来越多的人偏爱go语言

    如果你是一个开发者或者程序员,你大概应该听过Go语言或者Golang语言.当然,如果没有听过也没关系,看到这篇文章的同学,就说明你对Golang是关注的,只需要这一点就够了.今天来聊聊关于Golang ...

  6. java面向对象总结(一)

    1. 对象的概念及面向对象的三个基本特征 面向对象的三大核心特性 面向对象开发模式更有利于人们开拓思维,在具体的开发过程中便于程序的划分,方便程序员分工合作,提高开发效率.面向对象程序设计有以下优点. ...

  7. 内存管理 re模块

    # 内存垃圾回收机制: # 工作原理:引用计数 # 引用就+1 释放就是-1 当计数为0时 就会被垃圾回收机制回收 # 标记清除:解决循环引用导致的内存泄漏 # 标记:GC roots可以直接或间接访 ...

  8. bloc控制读写文件

    import 'package:flutter/material.dart'; import 'dart:io'; import 'package:path_provider/path_provide ...

  9. bzoj4665 小w的喜糖(dp+容斥)

    4665: 小w的喜糖 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 222  Solved: 130[Submit][Status][Discuss ...

  10. Gatling实战(三)

    无论是性能测试还是自动化测试,有一个很重要的点就是变量(参数化),因为真实环境是很少同时产生并发很高而且所有参数都一模一样的请求的,就算有这样的接口,开发肯定用缓存来挡了,这种一般不会是瓶颈,真正瓶颈 ...