Submission #543649

#TimeUsernameProblemLanguageResultExecution timeMemory
543649tudorXORanges (eJOI19_xoranges)C++17
100 / 100
547 ms8696 KiB
#include <iostream>

using namespace std;
const int nmax = 2e5;

int v[nmax + 1];
int aib[2][nmax + 1];
int n;

void update ( int p, int poz, int val ) {
    for ( ; poz <= n; poz += poz & -poz )
        aib[p][poz] ^= val;
}
int query ( int p, int poz ) {
    int rez = 0;
    for ( ; poz > 0; poz -= poz & -poz )
        rez ^= aib[p][poz];
    return rez;
}
int main () {
    int q, t, x, y;
    cin >> n >> q;
    for ( int i = 1; i <= n; i++ ) {
        cin >> v[i];
        update ( i % 2, i, v[i] );
    }
    for ( int i = 1; i <= q; i++ ) {
        cin >> t >> x >> y;
        if ( t == 1 ) {
            update ( x % 2, x, y ^ v[x] );
            v[x] = y;
        } else {
            if ( x % 2 == y % 2 )
                cout << ( query ( x % 2, x - 1 ) ^ query ( y % 2, y ) ) << '\n';
            else
                cout << 0 << '\n';
            
        }
    }
    
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...