답안 #930510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930510 2024-02-20T05:03:07 Z sleepntsheep XORanges (eJOI19_xoranges) C++17
100 / 100
97 ms 10324 KB
#include <stdio.h>

#define N 200000

int n, q;

struct st
{
    int t[N<<1];
    void upd(int p, int k)
    {
        for (t[p += n] = k; p >>= 1;) t[p] = t[p<<1] ^ t[p<<1|1];
    }

    int qry(int l, int r)
    {
        int z = 0;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1)
        {
            if (l&1) z ^= t[l++];
            if (r&1) z ^= t[--r];
        }
        return z;
    }
} t[2];

int a[N];

int main()
{
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; ++i) scanf("%d", a+i), t[i&1].upd(i, a[i]);

    for (int op, x, y; q--;)
    {
        scanf("%d%d%d", &op, &x, &y);
        switch (op)
        {
            case 1:
                --x;
                t[x&1].upd(x, y);
                break;
            default:
                --x, --y;
                if ((y - x) & 1)
                {
                    puts("0");
                }
                else
                {
                    printf("%d\n", t[x&1].qry(x, y+1));
                }
                break;
        }
    }

    return 0;
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:32:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     for (int i = 0; i < n; ++i) scanf("%d", a+i), t[i&1].upd(i, a[i]);
      |                                 ~~~~~^~~~~~~~~~~
xoranges.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d%d%d", &op, &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2652 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 10320 KB Output is correct
2 Correct 92 ms 10324 KB Output is correct
3 Correct 84 ms 10324 KB Output is correct
4 Correct 80 ms 9876 KB Output is correct
5 Correct 81 ms 10016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2652 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 90 ms 10320 KB Output is correct
16 Correct 92 ms 10324 KB Output is correct
17 Correct 84 ms 10324 KB Output is correct
18 Correct 80 ms 9876 KB Output is correct
19 Correct 81 ms 10016 KB Output is correct
20 Correct 79 ms 10064 KB Output is correct
21 Correct 97 ms 10084 KB Output is correct
22 Correct 79 ms 10012 KB Output is correct
23 Correct 81 ms 9812 KB Output is correct
24 Correct 80 ms 9808 KB Output is correct