• B. 01 Game【模拟】


    Problem - B - Codeforces

    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:

    1. delete s1s1 and s2s2: 1011001→110011011001→11001;
    2. delete s2s2 and s3s3: 1011001→110011011001→11001;
    3. delete s4s4 and s5s5: 1011001→101011011001→10101;
    4. delete s6s6 and s7s7: 1011001→101101011001→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 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.

    1. #include
    2. using namespace std;
    3. int t;
    4. string s;
    5. int main()
    6. {
    7. cin>>t;
    8. while(t--)
    9. {
    10. cin>>s;
    11. int count=0;
    12. for(int i=1;isize();i++)
    13. {
    14. if(s[i]!=s[i-1])
    15. {
    16. count++;
    17. s.erase(i-1,2);
    18. i=0;//从头开始遍历
    19. }
    20. }
    21. if(count%2==0)cout<<"NET"<
    22. else cout<<"DA"<
    23. }
    24. }

  • 相关阅读:
    软件配置管理计划
    11.7 校招 实习 内推 面经
    【Node.js入门】1.2 部署Node.js开发环境
    UE 虚幻引擎,项目结构
    去年最火的 JS 开源项目「GitHub 热点速览」
    MQTT C库下载
    如何使用Etherscan Remix插件验证智能合约
    MathType在word中的使用方法(要配合microsoft公式3.0才能使用)
    PHP Filter 函数
    【PI仿真笔记2-电容模型1】
  • 原文地址:https://blog.csdn.net/qq_62079079/article/details/125916858