QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345806 | #8311. Game on Sequence | black_moonrise# | WA | 1ms | 3864kb | C++14 | 1.0kb | 2024-03-07 15:08:05 | 2024-03-07 15:08:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
int n, m;
int a[MAXN*2];
set<pair<int,int> > S;
int last[256];
void add(int x, int n) {
S.erase(MP(last[x], x));
last[x] = n;
a[n] = x;
S.insert(MP(last[x], x));
}
bool f[256];
bool query(int x) {
memset(f, 0, sizeof(f));
bool ans;
for (auto it = S.rbegin(); it != S.rend(); it++) {
if (it->FF >= x) {
ans = f[x];
} else {
return ans;
}
if (!f[it->SS]) {
for (int t=0; t<8; t++) {
f[it->SS ^ (1<<t)] = true;
}
}
}
return f[x];
}
int main() {
for (int i=0; i<256; i++) {
S.insert(MP(0, i));
}
scanf("%d%d", &n, &m);
for (int i=1; i<=n; i++) {
int x;
scanf("%d", &x);
add(x, i);
}
for (int i=1; i<=m; i++) {
int op, x;
scanf("%d%d", &op, &x);
if (op==1) {
add(x, ++n);
} else {
// printf("%d\n", query(x));
puts(query(x) ? "Grammy" : "Alice");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
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: 3816kb
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: -100
Wrong Answer
time: 1ms
memory: 3772kb
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 Grammy Alice Alice Grammy Grammy Alice Grammy Grammy Grammy Grammy Grammy Alice Grammy Alice Alice Grammy Alice Grammy Alice Alice Alice Alice Grammy Grammy Grammy Alice Grammy Grammy Grammy Alice Alice Alice Grammy Grammy Alice Grammy Alice Grammy Alice Alice Alice Alice Grammy Alice
result:
wrong answer 3rd lines differ - expected: 'Alice', found: 'Grammy'