제출 #509729

#제출 시각아이디문제언어결과실행 시간메모리
509729tudorXORanges (eJOI19_xoranges)C++17
100 / 100
515 ms8716 KiB
#include <iostream>
using namespace std;
const int nmax = 2e5;
int aib[2][nmax + 1];
int n;
int v[nmax + 1];
int lsb ( int x ) {
    return x & ( -x );
}
void update ( int p, int poz, int val ) {
    for ( ; poz <= n; poz += lsb ( poz ) )
        aib[p][poz] ^= val;
}
int query ( int p, int poz ) {
    int rez = 0;
    for ( ; poz > 0; poz -= lsb ( poz ) )
        rez = 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...