题解:CF2171C1 Renako Amaori and XOR Game (easy version)
思路:
考虑贪心,既然只有
代码:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N = 2e5 + 10;
int t,n,a[N],b[N];
void solve(){
cin >> n;
int cnt1 = 0,cnt2 = 0;
bool f1 = 0,f2 = 0;
for(int i = 1;i <= n;i ++){cin >> a[i];cnt1 += a[i];}
for(int i = 1;i <= n;i ++){cin >> b[i];cnt2 += b[i];}
for(int i = 1;i <= n;i ++){
if(a[i] == b[i])continue;
if(i % 2){
if(cnt1 % 2 == 0){
if(a[i] == 1 and b[i] == 0){
cnt1 --;
cnt2 ++;
}
if(a[i] == 0 and b[i] == 1){
cnt1 ++;
cnt2 --;
}
}
}else{
if(cnt2 % 2 == 0){
if(a[i] == 0 and b[i] == 1){
cnt1 --;
cnt2 ++;
}
if(a[i] == 1 and b[i] == 0){
cnt2 ++;
cnt1 --;
}
}
}
}
if((cnt1 % 2 == 0 and cnt2 % 2 == 0) or (cnt1 % 2 and cnt2 % 2))puts("Tie");
else if(cnt1 % 2 == 0)puts("Mai");
else if(cnt2 % 2 == 0)puts("Ajisai");
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> t;
while(t --){
solve();
}
return 0;
}