Submission #1095448

# Submission time Handle Problem Language Result Execution time Memory
1095448 2024-10-02T08:31:49 Z thangdz2k7 XORanges (eJOI19_xoranges) C++17
100 / 100
77 ms 8788 KB
// author : thembululquaUwU
// 3.9.2024

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'

using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}

int n, q, a[N];

struct fen{
    int bit[N];

    void upd(int p, int x){
        for (; p <= n; p += p & -p) bit[p] ^= x;
    }

    int get(int l, int r){
        int ans = 0;
        for (l = l - 1; l; l -= l & -l) ans ^= bit[l];
        for (; r; r -= r & -r) ans ^= bit[r];
        return ans;
    }
} T[2];

void solve(){
    cin >> n >> q;
    for (int i = 1; i <= n; ++ i){
        cin >> a[i]; T[i & 1].upd(i, a[i]);
    }
    while (q --){
        int op, l, r; cin >> op >> l >> r;
        if (op & 1){
            T[l & 1].upd(l, a[l] ^ r); a[l] = r;
        }
        else {
            if ((r - l) & 1) cout << 0 << endl;
            else cout << T[l & 1].get(l, r) << endl;
        }
    }
}

int main(){
    if (fopen("pqh.inp", "r")){
        freopen("pqh.inp", "r", stdin);
        freopen("pqh.out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1; // cin >> t;
    while (t --) solve();
    return 0;
}

Compilation message

xoranges.cpp:18:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
xoranges.cpp:18:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
xoranges.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
xoranges.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
xoranges.cpp: In function 'int main()':
xoranges.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:58:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 8668 KB Output is correct
2 Correct 73 ms 8788 KB Output is correct
3 Correct 77 ms 8784 KB Output is correct
4 Correct 61 ms 8276 KB Output is correct
5 Correct 61 ms 8272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 644 KB Output is correct
15 Correct 68 ms 8668 KB Output is correct
16 Correct 73 ms 8788 KB Output is correct
17 Correct 77 ms 8784 KB Output is correct
18 Correct 61 ms 8276 KB Output is correct
19 Correct 61 ms 8272 KB Output is correct
20 Correct 60 ms 8524 KB Output is correct
21 Correct 62 ms 8364 KB Output is correct
22 Correct 64 ms 8352 KB Output is correct
23 Correct 64 ms 8272 KB Output is correct
24 Correct 60 ms 8336 KB Output is correct