Submission #760790

# Submission time Handle Problem Language Result Execution time Memory
760790 2023-06-18T12:59:46 Z bachhoangxuan XORanges (eJOI19_xoranges) C++17
100 / 100
76 ms 8676 KB
#include <bits/stdc++.h>
using namespace std;
#define maxn 200005
int bit[maxn][2],a[maxn],n,q;
void update(int t,int x,int val){
    for(int i=x;i<=n;i+=(i&(-i))) bit[i][t]^=val;
}
int query(int t,int x){
    int res=0;
    for(int i=x;i>=1;i-=(i&(-i))) res^=bit[i][t];
    return res;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        if(i%2==1) update(1,i,a[i]);
        else update(0,i,a[i]);
    }
    for(int i=1;i<=q;i++){
        int id,l,r;cin >> id >> l >> r;
        if(id==1){
            if(l%2==1) update(1,l,a[l]^r);
            else update(0,l,a[l]^r);
            a[l]=r;
        }
        else{
            if((r-l+1)%2==0) cout << 0 << '\n';
            else cout << (query(l%2,r)^query(l%2,l-1)) << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 8620 KB Output is correct
2 Correct 74 ms 8676 KB Output is correct
3 Correct 76 ms 8588 KB Output is correct
4 Correct 66 ms 8284 KB Output is correct
5 Correct 64 ms 8248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 70 ms 8620 KB Output is correct
16 Correct 74 ms 8676 KB Output is correct
17 Correct 76 ms 8588 KB Output is correct
18 Correct 66 ms 8284 KB Output is correct
19 Correct 64 ms 8248 KB Output is correct
20 Correct 72 ms 8396 KB Output is correct
21 Correct 69 ms 8412 KB Output is correct
22 Correct 66 ms 8412 KB Output is correct
23 Correct 65 ms 8248 KB Output is correct
24 Correct 69 ms 8268 KB Output is correct