QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#345810 | #8311. Game on Sequence | black_moonrise# | WA | 0ms | 3864kb | C++14 | 1.0kb | 2024-03-07 15:11:54 | 2024-03-07 15:11:56 |
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;
}
f[it->SS] = 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;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
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: 3864kb
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: 0ms
memory: 3664kb
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 Grammy Grammy Grammy Alice Grammy Alice Grammy Grammy Grammy Alice Alice Grammy Grammy Grammy Alice Grammy Grammy Grammy Alice Alice Alice Grammy Grammy Alice Grammy Alice Grammy Alice Grammy Alice Alice Grammy A...
result:
wrong answer 3rd lines differ - expected: 'Alice', found: 'Grammy'