0
点赞
收藏
分享

微信扫一扫

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

原题链接: ​​https://codeforces.com/problemset/problem/1373/B​​

B. 01 Game(思维)Educational Codeforces Round 90 (Rated for Div. 2)_操作数

测试样例

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.

题意: Alice和Bob玩游戏,游戏规则是Alice先开始,每人进行消去连续的两个不同字符操作,若无法进行,则输掉比赛。判断谁能赢得比赛。

解题思路: 这道题不用想太多,我们要知道,当无法进行操作的时候必定是没有0或者没有1了,若存在0和1那必然可以进行操作,所以操作数和01的数量有关,即操作数=B. 01 Game(思维)Educational Codeforces Round 90 (Rated for Div. 2)_#define_02。获取操作数后我们就可以知道了,对于Alice而言,他先开始,故奇数必赢,偶数必输,则此题易解。

AC代码

/*

*
*/
#include<bits/stdc++.h> //POJ不支持

#define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量,a为初始值,n为界限值,递增
#define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量, a为初始值,n为界限值,递减。
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define mp make_pair

using namespace std;

const int inf = 0x3f3f3f3f;//无穷大
const int maxn = 1e5;//最大值。
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
//*******************************分割线,以上为自定义代码模板***************************************//

int t;
string s;
int main(){
//freopen("in.txt", "r", stdin);//提交的时候要注释掉
IOS;
while(cin>>t){
while(t--){
int cnt0=0,cnt1=0;
cin>>s;
int n=s.size();
rep(i,0,n-1){
if(s[i]=='0'){
cnt0++;
}
else{
cnt1++;
}
}
cnt0=min(cnt0,cnt1);
if(cnt0%2==0){
cout<<"NET"<<endl;
}
else{
cout<<"DA"<<endl;
}
}
}
return 0;
}


举报

相关推荐

0 条评论