QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#374685 | #8311. Game on Sequence | PetroTarnavskyi# | WA | 1ms | 3788kb | C++20 | 1.4kb | 2024-04-02 17:02:06 | 2024-04-02 17:02:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int LOG = 8;
const int M = 1 << LOG;
int lastPos[M];
int win[M];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
fill(lastPos, lastPos + M, -1);
int n, m;
cin >> n >> m;
VI a(n);
FOR(i, 0, n)
{
cin >> a[i];
lastPos[a[i]] = i;
}
set<PII> s;
FOR(x, 0, M)
{
if (lastPos[x] != -1)
{
s.insert({-lastPos[x], x});
}
}
auto calcWin = [&]()
{
fill(win, win + M, -1);
for (auto [i, x] : s)
{
if (win[x] != -1)
{
assert(win[x] == 1);
continue;
}
win[x] = 0;
FOR(j, 0, LOG)
{
win[x ^ (1 << j)] = 1;
}
}
};
calcWin();
while (m--)
{
int op, k;
cin >> op >> k;
if (op == 1)
{
if (lastPos[k] != -1)
{
s.erase({-lastPos[k], k});
}
a.PB(k);
lastPos[k] = n++;
s.insert({-lastPos[k], k});
calcWin();
}
else
{
int x = a[k];
assert(win[x] != -1);
cout << (win[x] == 1 || k != lastPos[x] ? "Grammy\n" : "Alice\n");
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3788kb
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: 3528kb
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 Grammy Alice Alice
result:
wrong answer 2nd lines differ - expected: 'Grammy', found: 'Alice'