-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_Game.cpp
More file actions
46 lines (42 loc) · 1.04 KB
/
01_Game.cpp
File metadata and controls
46 lines (42 loc) · 1.04 KB
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
// in one move one can delete 01 or 10 from the array
// alice makes first move
// binary string is given and we need to find who will win
// game ends when no one can delete anything
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll testcases;
cin >> testcases;
for (ll testcase = 0; testcase < testcases; testcase++)
{
string binaryString;
cin >> binaryString;
ll count = 0, consecutives = 1;
char first = binaryString[0];
for (ll i = 1; i < binaryString.length(); i++)
{
if (binaryString[i] == first)
{
consecutives++;
}
else if(consecutives > 0){
count++;
consecutives--;
}
else{
first = binaryString[i];
consecutives = 1;
}
}
if (count % 2 == 0)
{
cout << "NET" << endl;
}
else
{
cout << "DA" << endl;
}
}
}