码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 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. }

  • 相关阅读:
    生成式AI爆发,安全问题如何解决?
    AOP获取通知以及实际应用
    Python 实现单例模式的五种写法
    室温离子液体1-丁基-3-甲基咪唑六氟磷酸盐([EMIM] PF6)科研试剂
    基于selenium的pyse自动化测试框架
    Dubbo源码(三) - 服务导出(生产者)
    傅里叶变换和其图像处理中的应用
    数据库迁移-国产化-Oracle迁移至GBase8a(操作符)
    【整合】LSTM 时间序列预测任务 Time-Series-Sine,实现正弦曲线的预测
    Redis五种常用数据类型有哪些?对应的数据存储空间又是怎样的?带你从零开始学习
  • 原文地址:https://blog.csdn.net/qq_62079079/article/details/125916858
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号