-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path01 Game.cpp
More file actions
executable file
·54 lines (51 loc) · 826 Bytes
/
01 Game.cpp
File metadata and controls
executable file
·54 lines (51 loc) · 826 Bytes
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
#include <bits/stdc++.h>
using namespace std;
// Easy Solution (Inspired by tmwilliamlin)
void solve() {
string s;
cin >> s;
int c[] = {0, 0};
for (char d : s)
c[d - '0']++;
cout << ((min(c[0], c[1]) & 1) ? "DA\n" : "NET\n");
}
// Complex Solution
void solve2() {
string s;
cin >> s;
char f = s[0];
int ctr = 0;
stack<char> st;
st.push(s[0]);
for (int i = 1; i < int(s.length()); i++) {
if (s[i] == f)
st.push(s[i]);
else {
if (!st.empty()) {
st.pop();
ctr++;
}
else {
f = s[i];
st.push(s[i]);
}
}
}
if (ctr % 2 == 0)
cout << "NET\n";
else
cout << "DA\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
cin >> t;
while (t--)
solve();
return 0;
}