Submission #794425

# Submission time Handle Problem Language Result Execution time Memory
794425 2023-07-26T14:13:39 Z Godgift42 XORanges (eJOI19_xoranges) C++14
75 / 100
1000 ms 8204 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n,q;
    cin >> n >> q;
    vector<long long> a,p;
    vector<long long> a2,p2;
    a.push_back(0);a2.push_back(0);
    p.push_back(0);p2.push_back(0);
    for(long long i=1;i<=n;i++){
        long long x;
        cin >> x;
        if(i%2==1){
            a.push_back(x^a[i/2]);
            p.push_back(x);
        }
        else{
            a2.push_back(x^a2[i/2-1]);
            p2.push_back(x);
        }
    }
    while(q--){
        long long action;
        cin >> action;
        if(action==1){
            long long pos,ch;
            cin >> pos >> ch;
            if(pos%2!=0){
                for(int i=1;i<=(n+1)/2;i++){
                    if(i==(pos+1)/2){
                        a[i]=a[i-1]^ch;
                        p[i]=ch;
                    }
                    else if(i>(pos+1)/2){
                        a[i]=a[i-1]^p[i];
                    }
                }
            }
            else {
                for(int i=1;i<=n/2;i++){
                    if(i==pos/2){
                        a2[i]=a2[i-1]^ch;
                        p2[i]=ch;
                    }
                    else if(i>pos/2){
                        a2[i]=a2[i-1]^p2[i];
                    }
                }
            }
        }
        else{
            long long l,u;
            cin >> l >> u;
            if((u-l)%2==1) cout << 0<<"\n";
            else{
                if(l%2==1){
                    long long xum =a[(u+1)/2]^a[l/2];
                    cout << xum <<"\n";
                }
                else{
                    long long xum=a2[u/2]^a2[(l/2)-1];
                    cout << xum <<"\n";
                }
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 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 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 212 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 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 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 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 18 ms 596 KB Output is correct
12 Correct 18 ms 568 KB Output is correct
13 Correct 12 ms 584 KB Output is correct
14 Correct 11 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 400 ms 8120 KB Output is correct
2 Correct 422 ms 8104 KB Output is correct
3 Correct 424 ms 8204 KB Output is correct
4 Correct 385 ms 8192 KB Output is correct
5 Correct 421 ms 8108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 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 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 18 ms 596 KB Output is correct
12 Correct 18 ms 568 KB Output is correct
13 Correct 12 ms 584 KB Output is correct
14 Correct 11 ms 596 KB Output is correct
15 Correct 400 ms 8120 KB Output is correct
16 Correct 422 ms 8104 KB Output is correct
17 Correct 424 ms 8204 KB Output is correct
18 Correct 385 ms 8192 KB Output is correct
19 Correct 421 ms 8108 KB Output is correct
20 Execution timed out 1050 ms 5872 KB Time limit exceeded
21 Halted 0 ms 0 KB -