답안 #773689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773689 2023-07-05T07:48:37 Z serifefedartar XORanges (eJOI19_xoranges) C++17
100 / 100
305 ms 11224 KB
#include <bits/stdc++.h>

using namespace std;

#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define mod 1000000007
#define MAXN 200005

vector<int> arr;
pair<int,int> sg[4*MAXN];

void init(int k, int a, int b) {
    if (a == b) {
        if (a % 2 == 0)
            sg[k] = {arr[a], 0};
        else
            sg[k] = {0, arr[a]};
        return ;
    }
    init(2*k, a, (a+b)/2);
    init(2*k+1, (a+b)/2+1, b);
    sg[k] = {sg[2*k].first ^ sg[2*k+1].first, sg[2*k].second ^ sg[2*k+1].second};
}

void point_update(int k, int a, int b, int plc, int val) {
    if (plc > b || plc < a)
        return ;
    if (a == b) {
        if (a % 2 == 0)
            sg[k] = {val, 0};
        else
            sg[k] = {0, val};
        return ;
    }

    point_update(2*k, a, (a+b)/2, plc, val);
    point_update(2*k+1, (a+b)/2+1, b, plc, val);
    sg[k] = {sg[2*k].first ^ sg[2*k+1].first, sg[2*k].second ^ sg[2*k+1].second};
}

pair<int,int> query(int k, int a, int b, int q_l, int q_r) {
    if (q_r < a || q_l > b)
        return {0, 0};
    if (q_l <= a && b <= q_r)
        return sg[k];

    pair<int,int> p1 = query(2*k, a, (a+b)/2, q_l, q_r);
    pair<int,int> p2 = query(2*k+1, (a+b)/2+1, b, q_l, q_r);
    return {p1.first ^ p2.first, p1.second ^ p2.second};
}

int main() {
    fast
    int n, q;
    cin >> n >> q;

    arr = vector<int>(n+1);
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    init(1, 1, n);

    while (q--) {
        int t, i, j;
        cin >> t >> i >> j;
        if (t == 1) {
            point_update(1, 1, n, i, j);
        } else {
            if ((j - i + 1) % 2 == 0)
                cout << 0 << endl;
            else {
                if (i % 2 == 0)
                    cout << query(1, 1, n, i, j).first << endl;
                else
                    cout << query(1, 1, n, i, j).second << endl;
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 220 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 220 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 5 ms 596 KB Output is correct
12 Correct 5 ms 596 KB Output is correct
13 Correct 7 ms 600 KB Output is correct
14 Correct 7 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 298 ms 11156 KB Output is correct
2 Correct 305 ms 11160 KB Output is correct
3 Correct 303 ms 11224 KB Output is correct
4 Correct 286 ms 10828 KB Output is correct
5 Correct 285 ms 10876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 220 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 5 ms 596 KB Output is correct
12 Correct 5 ms 596 KB Output is correct
13 Correct 7 ms 600 KB Output is correct
14 Correct 7 ms 612 KB Output is correct
15 Correct 298 ms 11156 KB Output is correct
16 Correct 305 ms 11160 KB Output is correct
17 Correct 303 ms 11224 KB Output is correct
18 Correct 286 ms 10828 KB Output is correct
19 Correct 285 ms 10876 KB Output is correct
20 Correct 199 ms 10952 KB Output is correct
21 Correct 194 ms 10964 KB Output is correct
22 Correct 201 ms 11088 KB Output is correct
23 Correct 295 ms 10848 KB Output is correct
24 Correct 277 ms 10780 KB Output is correct