1641. 狼人杀-简单版
摘要
Title: 1641. 狼人杀-简单版
Tag: 枚举
Memory Limit: 64 MB
Time Limit: 1000 ms
Powered by:NEFU AB-IN
1641. 狼人杀-简单版
-
题意
见原题
-
思路
枚举两只狼,并根据条件判断此状态是否成立
- 狼中只有一个说了假话
- 所有人只有两个人说了假话
-
代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using namespace std;
typedef pair<int, int> PII;
int main()
{
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; ++i)
cin >> a[i];
auto judge = [&](int k, int i, int j) {
int x = a[k];
if (x > 0)
{
if (x == i || x == j)
return 1;
return 0;
}
x = -x;
if (x == i || x == j)
return 0;
return 1;
};
for (int i = 1; i <= n; ++i)
{
for (int j = i + 1; j <= n; ++j)
{
int s = judge(i, i, j) + judge(j, i, j);
if (s != 1)
continue;
s = 0;
for (int k = 1; k <= n; ++k)
{
s += judge(k, i, j);
}
if (s != 2)
continue;
cout << i << " " << j << '\n';
return 0;
}
}
cout << "No Solution";
return 0;
}