QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#288000#7863. Parity Gameucup-team1447#RE 1ms3820kbC++144.3kb2023-12-21 14:56:332023-12-21 14:56:33

Judging History

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

  • [2023-12-21 14:56:33]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3820kb
  • [2023-12-21 14:56:33]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define int long long
#define ull unsigned long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define mod 998244353
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000005
#define inf 0x3f3f3f3f

int n,t;
int op,need,dumb;
vi o;

bool ok[maxn],ok2[maxn];
int win(vi o,int k){
	if(k==0){
		assert(o.size()%2==1);
		int sz=o.size();
		For(p,0,sz-2){
			vi o2;
			For(i,0,p-1) o2.pb(o[i]);
			o2.pb(0);
			For(i,p+1,(int)o.size()-1) o2.pb(o[i]);
			if(win(o2,!k)==-1)return p;
		}
		return -1;
	}else{
		assert(o.size()%2==0);
		int sz=o.size();
		ok[0]=o[0];
		for(int i=2;i<sz;i+=2) ok[i]=(ok[i-2]&&o[i]);
		ok2[sz-1]=o[sz-1];
		for(int i=sz-2;i>=0;i-=2) ok2[i]=(ok2[i+2]&&o[i]);
		
		For(i,0,sz-2){
			if(i%2==0){
				if(!o[i] && !o[i+1]) continue;
				if(i>=2 && !ok[i-2]) continue;
				if(i+3<=sz-1 && !ok2[i+3]) continue;
			}else{
				if(!ok[i-1]) continue;
				if(i+1<=sz-1 && !ok2[i+1]) continue;
			}
			
			return i;
		}
		return -1;
	}
}

void run(int p){
//	for(auto x:o)cout<<x<<" "; cout<<"nows\n";
	
	int x=o[p],y=o[p+1];
	if((x+y)%2==need) cout<<p+1<<" "<<"+"<<endl;
	else if((x*y)%2==need) cout<<p+1<<" "<<"*"<<endl;
	else assert(0);
	vi o2;
	For(i,0,p-1) o2.pb(o[i]);
	o2.pb(need);
	For(i,p+2,(int)o.size()-1) o2.pb(o[i]);
	o=o2;
}

void run2(){
	int p; cin>>p; --p;
	char ch; cin>>ch;
	int x=o[p],y=o[p+1],z;
	if(ch=='+') z=(x+y)%2;
	else z=(x*y)%2;

	vi o2;
	For(i,0,p-1) o2.pb(o[i]);
	o2.pb(z);
	For(i,p+2,(int)o.size()-1) o2.pb(o[i]);
	o=o2;
}

signed main()
{
	cin>>n>>t;
	o.resize(n);
	For(i,0,n-1)cin>>o[i];
		if(n%2==1){
			// last is bob
			if(t==1) op=0,need=0,dumb=1;
			else{
				if(win(o,0)!=-1) op=1,need=0;
				else op=0,need=1;
			}
		}else{
			// last is alice
			if(t==0) op=1,need=0,dumb=1;
			else{
				if(win(o,1)!=-1) op=1,need=1;
				else op=0,need=0;
			}
		}
	if(op) cout<<"Alice"<<endl;
	else cout<<"Bob"<<endl,run2();
	while(o.size()>1){
		if(dumb) run(0);
		else{
			int pos=win(o,need);
			assert(pos!=-1);
			run(pos);
		}
		if(o.size()>1) run2();
	}
	return 0;
}
/*
4
1 3 2 4
3 4 1 2
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

4 1
0 1 0 1
1 *
1

output:

Alice
1 +
1 +

result:

ok The player wins!

Test #2:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

4 0
1 0 1 0
1 +
1

output:

Alice
1 *
1 *

result:

ok The player wins!

Test #3:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

5 1
1 1 1 0 0
4 +
1 +
1

output:

Bob
1 +
1 *

result:

ok The player wins!

Test #4:

score: -100
Runtime Error

input:

3 0
1 1 1

output:


result: