Submission #344831

# Submission time Handle Problem Language Result Execution time Memory
344831 2021-01-06T15:45:33 Z spike1236 XORanges (eJOI19_xoranges) C++14
0 / 100
182 ms 6508 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

const int MAXN = 2e5 + 10;
int t[MAXN << 2][2];
int n, q;
int a[MAXN];

void upd(int pos, int val, int v = 1, int tl = 1, int tr = n) {
    if(tl == tr) {
        t[v][pos & 1] = val;
        return;
    }
    int tm = tl + tr >> 1;
    if(pos <= tm) upd(pos, val, v << 1, tl, tm);
    else upd(pos, val, v << 1 | 1, tm + 1, tr);
    for(int j = 0; j < 2; ++j)
        t[v][j] = t[v << 1][j] ^ t[v << 1 | 1][j];
}

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

void solve() {
    cin >> n >> q;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        upd(i, a[i]);
    }
    for(int i = 1; i <= q; ++i) {
        int type, l, r;
        cin >> type >> l >> r;
        if(type == 1) a[l] = r, upd(l, r);
        else {
            if((r - l) % 2) cout << "0\n";
            else cout << get(l, r) << '\n';
        }
    }
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}

Compilation message

xoranges.cpp: In function 'void upd(int, int, int, int, int)':
xoranges.cpp:34:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |     int tm = tl + tr >> 1;
      |              ~~~^~~~
xoranges.cpp: In function 'int get(int, int, int, int, int)':
xoranges.cpp:44:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   44 |     int tm = tl + tr >> 1;
      |              ~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 6508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -