QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#48597#4389. CopylqhsmashAC ✓143ms5380kbC++111.6kb2022-09-14 17:14:062022-09-14 17:14:08

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-14 17:14:08]
  • 评测
  • 测评结果:AC
  • 用时:143ms
  • 内存:5380kb
  • [2022-09-14 17:14:06]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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