-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1373B - 01 Game.cpp
124 lines (83 loc) · 2.34 KB
/
1373B - 01 Game.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
Alica and Bob are playing a game.
Initially they have a binary string s consisting of only characters 0 and 1.
Alice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice makes the third one, and so on. During each move, the current player must choose two different adjacent characters of string s and delete them. For example, if s=1011001 then the following moves are possible:
delete s1 and s2: 1011001?11001;
delete s2 and s3: 1011001?11001;
delete s4 and s5: 1011001?10101;
delete s6 and s7: 1011001?10110.
If a player can't make any move, they lose. Both players play optimally. You have to determine if Alice can win.
Input
First line contains one integer t (1=t=1000) — the number of test cases.
Only line of each test case contains one string s (1=|s|=100), consisting of only characters 0 and 1.
Output
For each test case print answer in the single line.
If Alice can win print DA (YES in Russian) in any register. Otherwise print NET (NO in Russian) in any register.
Example
inputCopy
3
01
1111
0011
outputCopy
DA
NET
NET
Note
In the first test case after Alice's move string s become empty and Bob can not make any move.
In the second test case Alice can not make any move initially.
In the third test case after Alice's move string s turn into 01. Then, after Bob's move string s become empty and Alice can not make any move.
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int zero = 0, one = 0;
for (auto &x: s) {
if (x == '0') zero++;
}
one = s.length() - zero;
int res = min(zero, one);
res % 2 ? cout << "DA\n" : cout << "NET\n";
}
return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int zero = 0, one = 0;
for (auto &x: s) {
if (x == '0') zero++;
}
one = s.length() - zero;
bool res = false; // true -> Alice Wins
while (zero > 0 && one > 0) {
for (int i = 0; i < s.length() - 1; i++) {
if (s[i] != s[i + 1]) {
s.erase(i, 2);
res = !res;
zero -= 1;
one -= 1;
i -= 2;
}
}
}
res ? cout << "DA\n" : cout << "NET\n";
}
return 0;
}
*/