QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#354014#8311. Game on SequencePlentyOfPenalty#WA 1ms3664kbC++201.2kb2024-03-14 20:31:362024-03-14 20:31:37

Judging History

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

  • [2024-03-14 20:31:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3664kb
  • [2024-03-14 20:31:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 2e5,K=255;
int n,m,a[(N<<1)+10],pos[K+10],f[K+10],ls[K+10],nx[K+10],tp,lst,fl;
int op,k;
int Calc(int x){
	for(int i=0;i<8;++i)if(pos[x^(1<<i)]>pos[x]&&!f[x^(1<<i)])return 1;
	return 0;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=n;i>=1;--i)if(!pos[a[i]]){
		pos[a[i]]=i;
		if(!tp)tp=a[i],nx[a[i]]=K+1,ls[K+1]=a[i];
		else ls[lst]=a[i],nx[a[i]]=lst;
		f[a[i]]=Calc(a[i]);
		lst=a[i];
	}
	ls[lst]=K+2,nx[K+2]=lst;
	while(m--){
		cin>>op>>k;
		if(op==1){
			f[k]=0;
			if(pos[k]){
				ls[nx[k]]=ls[k],nx[ls[k]]=nx[k];
				if(tp==k)tp=ls[k];
			}
			pos[k]=++n,a[n]=k;
			for(int t=tp;t<=K;t=ls[t])f[t]=Calc(t);
			ls[k]=tp,nx[tp]=k,tp=k;
			//for(int i=1;i<=n;++i)cout<<a[i]<<" \n"[i==n];
			//for(int i=tp;i<=K;i=ls[i])cout<<"("<<i<<","<<f[i]<<")\n";
		}else{
			fl=0;
			if(pos[a[k]]==k)fl=f[k];
			else{
				fl=(f[k]^1);
				for(int i=0;i<8&&!fl;++i)if(pos[a[k]^(1<<i)]>k&&!f[a[k]^(1<<i)])fl=1;
			}
			cout<<(fl?"Grammy":"Alice")<<"\n";
		}
	}
}
/*
5 5
1 2 3 4 5
1 6
2 5
1 7
2 5
2 1

9 12
1 1 1 2 2 2 3 3 3
1 1
2 1
2 4
2 7
1 2
2 1
2 4
2 7
1 3
2 1
2 4
2 7


*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3660kb

input:

5 5
1 2 3 4 5
1 6
2 5
1 7
2 5
2 1

output:

Alice
Grammy
Alice

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3664kb

input:

10 10
12 114 132 7 133 53 128 159 34 92
2 5
1 254
2 3
2 11
1 92
2 11
1 33
1 230
1 181
2 11

output:

Alice
Alice
Alice
Alice
Alice

result:

wrong answer 2nd lines differ - expected: 'Grammy', found: 'Alice'