QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#48597 | #4389. Copy | lqhsmash | AC ✓ | 143ms | 5380kb | C++11 | 1.6kb | 2022-09-14 17:14:06 | 2022-09-14 17:14:08 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 50;
int T, q, n, a[N];
bitset<N> ans;
struct node {
int op, x, y;
}qur[N];
int main() {
#ifdef LOCAL
clock_t c1 = clock();
freopen("in.in", "r", stdin);
freopen("out.out", "w", stdout);
#endif
// ===================================================
scanf ("%d", &T);
while (T --) {
scanf ("%d%d", &n, &q);
for (int i = 1; i <= n; i ++) {
scanf ("%d", &a[i]);
}
ans.reset ();
for (int i = 1; i <= q; i ++) {
int op, x, l, r; scanf ("%d", &op);
if (op == 1) {
scanf ("%d%d", &l, &r);
qur[i] = {op, l, r};
}else {
scanf ("%d", &x);
qur[i] = {op, x};
}
}
for (int i = q; i >= 1; i --) {
int op = qur[i].op;
if (op == 1) {
int l = qur[i].x, r = qur[i].y;
bitset<N> f = ans & (~bitset<N> (0) >> (N - r - 1));
bitset<N> g = ans & (~bitset<N> (0) << (r + 1));
ans = f ^ (g >> (r - l + 1));
}else {
int x = qur[i].x;
ans[x].flip ();
}
}
// cerr << ans << endl;
int res = 0;
for (int i = 1; i <= n; i ++)
if (ans[i]) res ^= a[i];
printf("%d\n", res);
}
// ===================================================
#ifdef LOCAL
cerr << "Time Used: " << clock() - c1 << "ms" << endl;
#endif
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 143ms
memory: 5380kb
input:
2 5 10 14138491 23289232 33892225 43531245 54436322 1 1 4 2 2 2 3 2 4 2 5 1 2 4 2 2 2 3 2 4 2 5 99990 99990 493133979 94198606 751145654 147404311 601524088 744747426 561746143 212260573 241231749 810352224 81276441 382492450 18779020 317505899 880615584 654793240 417574821 822313301 140569958 69317...
output:
28631531 787379207
result:
ok 2 lines