Alica and Bob are playing a game.
Initially they have a binary string ss 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 ss and delete them. For example, if s=1011001s=1011001 then the following moves are possible:
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 tt (1≤t≤10001≤t≤1000) — the number of test cases.
Only line of each test case contains one string ss (1≤|s|≤1001≤|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
input
Copy
3 01 1111 0011
output
Copy
DA NET NET
Note
In the first test case after Alice's move string ss 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 ss turn into 0101. Then, after Bob's move string ss become empty and Alice can not make any move.
- #include
- using namespace std;
- int t;
- string s;
- int main()
- {
- cin>>t;
- while(t--)
- {
- cin>>s;
- int count=0;
- for(int i=1;i
size();i++) - {
- if(s[i]!=s[i-1])
- {
- count++;
- s.erase(i-1,2);
- i=0;//从头开始遍历
- }
- }
- if(count%2==0)cout<<"NET"<
- else cout<<"DA"<
- }
- }
-
相关阅读:
JAVA后端工程师笔试题-避坑公司
javascript 变量原理
【代码随想录】算法训练计划03
nodejs+vue智能招聘系统elementui
Kotlin 协程再探之为什么使用协程反而更慢了?
【LeetCode热题100】--102.二叉树的层序遍历
苹果电脑双系统正确打开方式,虚拟机已经Out了
AI辅助研发对医药、汽车和电子行业的影响
有效需求分析培训梳理(二)
CVE-2022-22965 Spring Framework远程命令执行
-
原文地址:https://blog.csdn.net/qq_62079079/article/details/125916858