Educational Codeforces Round 90 (Rated for Div. 2) B. 01 Game(思维博弈)

01 Game:

题目大意:(文末有原题)

DA与NET玩游戏,给一个01串,他们只能删除 相邻的两个不同字符,DA先删,如果一个人没法删除,这个人就输了,判断最后谁会获胜;

思路:

因为是01串,所以能删多少次,与字符串的位置没有关系(只要既有1又有0,总会有相邻的01),所以只需判断有几个01对;

代码:

#include <iostream>
#include <cstring>
using namespace std;

int main() {
	int t;
	cin >> t;
	while(t--) {
		char c[1010];
		cin >> c;
		int len = strlen(c), s1 = 0, s0 = 0;
		
		for(int i = 0; i < len; i++) {
			if(c[i] == '1') s1++;
			else s0++;
		}
		
		if(s1 < s0) {
			if(s1 % 2)
				cout << "DA" << endl;
			else 
				cout << "NET" << endl;
		}else {
			if(s0 % 2) 
				cout << "DA" << endl;
			else
				cout << "NET" << endl;
		}
	}
	
	return 0;
}

//比赛时候把cin写在取长度len之后了,惨遭hacking(ಥ_ಥ)


原题:

题目:

Alica and Bob are playing a game.

Initially they have a binary string s 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 s and delete them. For example, if s=1011001 then the following moves are possible:

  1. delete s1 and s2: 1011001→11001;
  2. delete s2 and s3: 1011001→11001;
  3. delete s4 and s5: 1011001→10101;
  4. delete s6 and s7: 1011001→10110.

If a player can't make any move, they lose. Both players play optimally. You have to determine if Alice can win.

输入:

First line contains one integer t (1≤t≤1000) — the number of test cases.

Only line of each test case contains one string s (1≤|s|≤100), consisting of only characters 0 and 1.

输出:

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.

样例:

Input:

3
01
1111
0011

Output:

DA
NET
NET

Note

In the first test case after Alice's move string s 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 s turn into 01. Then, after Bob's move string s become empty and Alice can not make any move.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值