Submission #791395

# Submission time Handle Problem Language Result Execution time Memory
791395 2023-07-24T05:44:30 Z otarius XORanges (eJOI19_xoranges) C++17
0 / 100
155 ms 11188 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair <int, int>
#define ull unsigned long long

// #define int long long
// #define int unsigned long long

const ll inf = 1e9 + 7;
const ll weirdMod = 998244353;

int t[800040][2];
void update(int v, int tl, int tr, int pos, int val) {
    if (tl == tr) {
        t[v][pos & 1] = val;
        return;
    } int tm = (tl + tr) / 2;
    if (pos <= tm)
        update(2 * v, tl, tm, pos, val);
    else update(2 * v + 1, tm + 1, tr, pos, val);
    t[v][0] = (t[2 * v][0] ^ t[2 * v + 1][0]);
    t[v][1] = (t[2 * v][1] ^ t[2 * v + 1][1]);
}
int getans(int v, int tl, int tr, int l, int r, int idx) {
    if (l > r) return 0;
    if (tl == l && tr == r)
        return t[v][idx];
    int tm = (tl + tr) / 2;
    return (getans(2 * v, tl, tm, l, min(r, tm), idx) ^
            getans(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, idx));
}
void solve() {
    int n, q;
    cin >> n >> q;
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        update(1, 1, n, i, x);
    } int tc, l, r;
    for (int i = 1; i <= q; i++) {
        cin >> tc >> l >> r;
        if (tc == 1) update(1, 1, n, l, r);
        else {
            if ((r - l + 1) & 1 == 0)
                cout << "0\n";
            else cout << getans(1, 1, n, l, r, l & 1) << '\n';
        }
    }
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
        cout << '\n';
    }
    return 0;
}

Compilation message

xoranges.cpp: In function 'void solve()':
xoranges.cpp:57:33: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   57 |             if ((r - l + 1) & 1 == 0)
      |                               ~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 155 ms 11188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -