QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350327#7863. Parity Gameushg8877Compile Error//C++141.5kb2024-03-10 17:16:522024-03-10 17:16:52

Judging History

你现在查看的是最新测评结果

  • [2024-03-10 17:16:52]
  • 评测
  • [2024-03-10 17:16:52]
  • 提交

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[x]=a[x+1];
	n--;
}
void step(char c,int x,int o){
	if(o) cout<<c<<' '<<x<<endl;
	oper(c,x);
}
void oppe(){
	// char c;int x;
	cin>>c>>x;
	c="*+"[rnd()&1],x=rnd()%(n-1)+1;
	step(c,x,1);
}
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])) {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

answer.code: In function ‘void oppe()’:
answer.code:20:14: error: ‘c’ was not declared in this scope
   20 |         cin>>c>>x;
      |              ^
answer.code:20:17: error: ‘x’ was not declared in this scope
   20 |         cin>>c>>x;
      |                 ^