QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#354017 | #8311. Game on Sequence | PlentyOfPenalty# | TL | 1ms | 3716kb | C++20 | 1.2kb | 2024-03-14 20:34:35 | 2024-03-14 20:34:35 |
Judging History
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[a[k]];
else{
fl=(f[a[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: 3692kb
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: 0
Accepted
time: 0ms
memory: 3716kb
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 Grammy Alice Alice Alice
result:
ok 5 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
100 100 57 58 24 217 80 0 241 175 19 138 231 17 8 19 22 100 133 205 178 67 55 92 127 254 156 89 87 22 136 208 168 195 164 194 243 110 234 164 78 55 43 223 227 112 137 78 111 31 253 194 196 128 210 129 71 129 40 195 114 69 114 52 83 162 248 117 12 162 86 155 81 6 251 174 237 190 171 44 61 114 254 131...
output:
Grammy Grammy Alice Alice Grammy Grammy Alice Alice Grammy Alice Grammy Grammy Grammy Alice Grammy Alice Alice Alice Alice Grammy Alice Grammy Alice Grammy Alice Grammy Grammy Alice Grammy Grammy Alice Alice Grammy Grammy Grammy Alice Alice Grammy Alice Grammy Grammy Grammy Grammy Alice Grammy Grammy
result:
ok 46 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
200 200 56 236 246 71 3 39 174 73 229 150 161 184 163 240 96 38 57 65 238 184 84 105 70 169 217 155 211 197 92 224 245 239 170 146 131 155 63 225 68 84 208 81 117 55 195 58 70 118 178 71 93 215 236 248 81 51 244 32 48 247 0 103 249 166 123 200 35 84 131 20 21 45 108 110 171 236 59 206 184 100 43 126...
output:
Grammy Alice Alice Grammy Alice Grammy Grammy Grammy Grammy Grammy Grammy Grammy Alice Grammy Alice Alice Grammy Grammy Alice Alice Grammy Grammy Alice Grammy Alice Grammy Grammy Grammy Grammy Grammy Grammy Grammy Grammy Alice Alice Alice Grammy Grammy Grammy Grammy Grammy Grammy Grammy Grammy Alice...
result:
ok 101 lines
Test #5:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
300 300 54 158 213 181 183 78 108 227 182 162 92 95 62 204 169 232 236 181 43 45 114 118 12 84 21 222 78 116 48 240 67 26 175 97 19 200 149 30 57 113 118 196 6 255 253 38 29 206 104 203 245 46 7 110 91 228 192 124 237 169 142 153 159 170 253 27 58 6 176 141 216 84 220 46 106 26 202 112 50 87 89 121 ...
output:
Grammy Grammy Grammy Alice Alice Alice Alice Grammy Alice Grammy Alice Grammy Grammy Grammy Alice Grammy Grammy Grammy Alice Grammy Alice Grammy Grammy Grammy Grammy Grammy Grammy Grammy Grammy Grammy Grammy Alice Grammy Alice Grammy Grammy Grammy Grammy Grammy Grammy Alice Grammy Alice Alice Grammy...
result:
ok 155 lines
Test #6:
score: -100
Time Limit Exceeded
input:
1000 1000 88 174 158 173 160 193 246 152 104 28 88 9 127 191 219 89 232 253 13 117 89 254 110 96 189 62 243 175 178 12 132 11 12 12 126 179 80 182 49 247 58 213 98 190 55 8 203 1 235 68 151 77 173 80 230 69 6 71 79 30 54 26 89 34 175 12 0 46 152 52 55 51 75 254 96 184 215 170 213 86 126 204 99 59 56...