Submission #543649

# Submission time Handle Problem Language Result Execution time Memory
543649 2022-03-31T07:18:25 Z tudor XORanges (eJOI19_xoranges) C++17
100 / 100
547 ms 8696 KB
#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 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 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 2 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 2 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 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 10 ms 468 KB Output is correct
12 Correct 10 ms 448 KB Output is correct
13 Correct 11 ms 468 KB Output is correct
14 Correct 12 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 537 ms 6396 KB Output is correct
2 Correct 487 ms 8564 KB Output is correct
3 Correct 508 ms 8696 KB Output is correct
4 Correct 547 ms 8360 KB Output is correct
5 Correct 522 ms 8308 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 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 10 ms 468 KB Output is correct
12 Correct 10 ms 448 KB Output is correct
13 Correct 11 ms 468 KB Output is correct
14 Correct 12 ms 488 KB Output is correct
15 Correct 537 ms 6396 KB Output is correct
16 Correct 487 ms 8564 KB Output is correct
17 Correct 508 ms 8696 KB Output is correct
18 Correct 547 ms 8360 KB Output is correct
19 Correct 522 ms 8308 KB Output is correct
20 Correct 392 ms 8332 KB Output is correct
21 Correct 386 ms 8308 KB Output is correct
22 Correct 387 ms 8376 KB Output is correct
23 Correct 474 ms 8280 KB Output is correct
24 Correct 467 ms 8380 KB Output is correct