-
Notifications
You must be signed in to change notification settings - Fork 8
/
#1114 小Hi小Ho的惊天大作战:扫雷·一AC.cpp
75 lines (65 loc) · 1.13 KB
/
#1114 小Hi小Ho的惊天大作战:扫雷·一AC.cpp
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX 100005
using namespace std;
int n, a[MAX],up[MAX],ans[MAX];
void dfs(int pos)
{
if (pos == n+1)
{
for (int i = 1; i <= n; i++)
{
if(ans[i]==-1) ans[i] = up[i];
else if (ans[i] != up[i]) ans[i] = 2; //存在几种可能的情况下,如果不都是0,或不都是1,至为2.
}
return;
}
for (int i = 0; i < 2; i++)
{
up[pos] = i;
if (up[pos] + up[pos - 1]>a[pos])
continue;
if (pos > 1 && up[pos] + up[pos - 1] + up[pos - 2] != a[pos - 1])
continue;
if (pos == n && up[pos] + up[pos - 1] != a[pos])
continue;
dfs(pos + 1);
}
}
int main()
{
int task;
cin >> task;
while (task--)
{
int x=0, o=0;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
memset(ans, -1, sizeof(ans));
dfs(1);
for (int i = 1; i <= n; i++)
{
if (ans[i] == 0)
o++;
else if (ans[i] == 1)
x++;
}
cout << x;
for (int i = 1; i <= n; i++){
if (ans[i] == 1)
cout << " " << i;
}
cout << endl;
cout << o;
for (int i = 1; i <= n; i++){
if (ans[i] == 0)
cout << " " << i;
}
cout << endl;
}
system("pause");
}