题目传送门:B. 01 Game
题目大意
给定一个01串,两个人轮流操作,每次只能删除两个相邻并且不同的两个数(也就是只能删除“01”或者“10”,删完后剩下的又会连起来变成相邻的),最后不能再操作的输,先手赢输出"DA",否则输出"NET"
思路
每次要删除也只能删除一个0和一个1,并且很容易想到最后只会剩下全是0或者全是1,那么不管怎么操作,操作总数num都是固定不变为01串里0的个数和1的个数中的最小值,即min(num0, num1)
那么如果num为奇数那么先手赢,反之,后手赢
代码
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> pll;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
ll qpow(ll base, ll n){ll ans = 1; while (n){if (n & 1) ans = ans * base % mod; base =