답안 #779328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
779328 2023-07-11T10:32:46 Z vjudge1 XORanges (eJOI19_xoranges) C++17
100 / 100
317 ms 8124 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
int n, q, opt, x, y, tree[2][200005], a[200005];
// tree[0 / 1] 表示 l 为[偶 / 奇]数时的树状数组

inline int lowbit(int x)
{
    return x & (-x);
}

inline void add(int x, int y, int f)
{
    while(x <= n) tree[f][x] ^= y, x += lowbit(x);
}

inline void build()
{
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        add(i, a[i], i % 2);
    }
}

inline int query(int x, int f)
{
    int sum = 0;
    while(x) sum ^= tree[f][x], x -= lowbit(x);
    return sum;
}

signed main()
{
    ios :: sync_with_stdio(false);
    cin >> n >> q;
    build();
    while(q--)
    {
        cin >> opt >> x >> y;
        if(opt == 1)
        {
            add(x, a[x] ^ y, x % 2);
            a[x] = y;
        }
        else if((x + y) & 1) cout << "0\n";
        else cout << (query(y, x % 2) ^ query(x - 1, x % 2)) << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 580 KB Output is correct
13 Correct 7 ms 468 KB Output is correct
14 Correct 8 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 293 ms 6944 KB Output is correct
2 Correct 286 ms 8012 KB Output is correct
3 Correct 317 ms 8096 KB Output is correct
4 Correct 270 ms 8116 KB Output is correct
5 Correct 284 ms 8124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 580 KB Output is correct
13 Correct 7 ms 468 KB Output is correct
14 Correct 8 ms 596 KB Output is correct
15 Correct 293 ms 6944 KB Output is correct
16 Correct 286 ms 8012 KB Output is correct
17 Correct 317 ms 8096 KB Output is correct
18 Correct 270 ms 8116 KB Output is correct
19 Correct 284 ms 8124 KB Output is correct
20 Correct 185 ms 7416 KB Output is correct
21 Correct 170 ms 7512 KB Output is correct
22 Correct 171 ms 7464 KB Output is correct
23 Correct 255 ms 7968 KB Output is correct
24 Correct 260 ms 8024 KB Output is correct