답안 #286512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286512 2020-08-30T13:56:25 Z MasterTaster XORanges (eJOI19_xoranges) C++14
100 / 100
942 ms 11128 KB
#include <bits/stdc++.h>
#define MAXN 200007

using namespace std;

long long n, q, arr[MAXN], bitEven[MAXN], bitOdd[MAXN];

void updEven(int x, int v)
{
    while (x<MAXN)
    {
        bitEven[x]^=v;
        x+=x&(-x);
    }
}
void updOdd(int x, int v)
{
    while (x<=MAXN)
    {
        bitOdd[x]^=v;
        x+=x&(-x);
    }
}

int xorEven(int x)
{
    long long ress=0;
    while (x)
    {
        ress^=bitEven[x];
        x-=x&(-x);
    }

    return ress;
}
int xorOdd(int x)
{
    long long ress=0;
    while (x)
    {
        ress^=bitOdd[x];
        x-=x&(-x);
    }

    return ress;
}

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

    for (int i=1; i<=n; i++)
    {
        cin>>arr[i];
        if (i%2==0)
        {
            updEven(i, arr[i]);
            updOdd(i, 0);
        }
        if (i%2==1)
        {
            updOdd(i, arr[i]);
            updEven(i, 0);
        }
    }

    while (q--)
    {
        int t;
        cin>>t;
        if (t==1)
        {
            int x, y;
            cin>>x>>y;
            if (x%2==0) updEven(x, y^arr[x]);
            else updOdd(x, y^arr[x]);
            arr[x]=y;
        }
        else
        {
            int l, r;
            cin>>l>>r;
            if ((r-l+1)%2==0) cout<<0<<endl;
            else
            {
                if (l%2==0)
                {
                    if (l==2) cout<<xorEven(r)<<endl;
                    else cout<<(xorEven(r)^xorEven(l-2))<<endl;
                }
                else
                {
                    if (l==1) cout<<xorOdd(r)<<endl;
                    else cout<<(xorOdd(r)^xorOdd(l-2))<<endl;
                }
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 21 ms 640 KB Output is correct
12 Correct 22 ms 640 KB Output is correct
13 Correct 22 ms 640 KB Output is correct
14 Correct 22 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 941 ms 11124 KB Output is correct
2 Correct 932 ms 11128 KB Output is correct
3 Correct 942 ms 11128 KB Output is correct
4 Correct 912 ms 10744 KB Output is correct
5 Correct 900 ms 10744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 21 ms 640 KB Output is correct
12 Correct 22 ms 640 KB Output is correct
13 Correct 22 ms 640 KB Output is correct
14 Correct 22 ms 640 KB Output is correct
15 Correct 941 ms 11124 KB Output is correct
16 Correct 932 ms 11128 KB Output is correct
17 Correct 942 ms 11128 KB Output is correct
18 Correct 912 ms 10744 KB Output is correct
19 Correct 900 ms 10744 KB Output is correct
20 Correct 743 ms 10872 KB Output is correct
21 Correct 740 ms 10872 KB Output is correct
22 Correct 742 ms 10872 KB Output is correct
23 Correct 885 ms 10872 KB Output is correct
24 Correct 874 ms 10744 KB Output is correct