QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#350336 | #7863. Parity Game | ushg8877 | WA | 0ms | 3700kb | C++14 | 1.6kb | 2024-03-10 17:26:30 | 2024-03-10 17:26:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
const int MAXN=505;
mt19937 rnd(time(0));
int n,o,a[MAXN],oa[MAXN],on;
void oper(char c,int x){
if(c=='+') a[x]=a[x]^a[x+1];
else a[x]=a[x]&a[x+1];
for(int i=x+1;i<n;i++) a[i]=a[i+1];
n--;
}
void step(char c,int x,int o){
if(o) cout<<x<<' '<<c<<endl;
oper(c,x);
}
void oppe(){
char c;int x;
cin>>x>>c;
// c="*+"[rnd()&1],x=rnd()%(n-1)+1;
step(c,x,0);
}
void Stg(int t,int o=0){
// t=0 表示进攻
// t=1 表示防守
if(t==0){
for(int i=1;i<n;i++) if(a[i]&&a[i+1]) {step('+',i,o);return;}
for(int i=1;i<n;i++) if(a[i]^a[i+1]) {step('*',i,o);return;}
step('+',1,o);
}else{
for(int i=1;i<n;i++) if(a[i]+a[i+1]==0) {step('+',i,o);return;}
if(a[1]==0){step('+',1,o);return;}
if(a[n]==0){step('+',n-1,o);return;}
for(int i=1;i<n;i++) if(a[i]^a[i+1]){step('+',i,o);return;}
step('*',1,o);
}
}
int main(){
// freopen("Otomachi_Una.in","r",stdin);
// freopen("Otomachi_Una.out","w",stdout);
cin>>n>>o;
for(int i=1;i<=n;i++) cin>>a[i];
if((n&1)^(o==0)){
if(n&1) cout<<"Bob"<<endl;
else cout<<"Alice"<<endl,step('+',1,1);
while(n>=4) step('+',1,1),oppe();
step("*+"[a[1]==a[2]],1,1);
}else{
memcpy(oa,a,sizeof(a));on=n;
while(n>=2){
Stg(o);
if(n>=2) Stg(!o);
}
if(a[1]==o){
memcpy(a,oa,sizeof(oa));n=on;
cout<<"Alice"<<endl;
while(n>=2){
Stg(o,1);
if(n>=2) oppe();
}
}else{
memcpy(a,oa,sizeof(oa));n=on;
cout<<"Bob"<<endl;
while(n>=2){
oppe();
if(n>=2) Stg(!o,1);
}
}
}
// cout<<"Final: "<<a[1]<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
input:
4 1 0 1 0 1 1 * 1
output:
Alice 1 + 1 +
result:
ok The player wins!
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3700kb
input:
4 0 1 0 1 0 1 * 0
output:
Alice 1 + 1 +
result:
wrong answer The interactor wins!