Submission #634037

# Submission time Handle Problem Language Result Execution time Memory
634037 2022-08-23T17:48:29 Z antimirage XORanges (eJOI19_xoranges) C++14
0 / 100
540 ms 8056 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>

using namespace std;

const int N = 1e6 + 5;

int n, q, a[N], type, l, r, t[2][N * 4];

void build (int v = 1, int tl = 1, int tr = n) {
    if (tl == tr) {
        t[tl & 1][v] = a[tl];
    } else {
        int tm = (tl + tr) >> 1;
        build(v + v, tl, tm);
        build(v + v + 1, tm + 1, tr);
        t[0][v] = t[0][v + v] ^ t[0][v + v + 1];
        t[1][v] = t[1][v + v] ^ t[1][v + v + 1];
    }
}
void update (int pos, int val, int v = 1, int tl = 1, int tr = n) {
    if (tl == tr) {
        t[tl & 1][v] = val;
    } else {
        int tm = (tl + tr) >> 1;
        if (pos <= tm)
            update(pos, val, v + v, tl, tm);
        else
            update(pos, val, v + v + 1, tm + 1, tr);
        t[0][v] = t[0][v + v] ^ t[0][v + v + 1];
        t[1][v] = t[1][v + v] ^ t[1][v + v + 1];
    }
}
int get (int l, int r, int v = 1, int tl = 1, int tr = n) {
    if (l > tr || tl > r)
        return 0;
        
    if (l <= tl && tr <= r)
        return t[tl & 1][v];
        
    int tm = (tl + tr) >> 1;
    
    return get(l, r, v + v, tl, tm) ^ get(l, r, v + v + 1, tm + 1, tr);
}

main(){
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    build();
    while (q--) {
        cin >> type >> l >> r;
        if (type == 1) {
            update(l, r);
        } else {
            if ((r - l + 1) & 1) {
                printf("%d\n", get(l, r));
            } else {
                puts("0");
            }
        }
    }
}

Compilation message

xoranges.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
xoranges.cpp: In function 'int main()':
xoranges.cpp:53:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 540 ms 8056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -