답안 #815698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815698 2023-08-08T19:03:20 Z AndrijaM XORanges (eJOI19_xoranges) C++14
75 / 100
269 ms 8620 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n,t;
    cin>>n>>t;
    int x[n];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
    }
    int xorval[n][2];
    int pom=0;
    for(int i=0;i<n;i+=2)
    {
        pom^=x[i];
        xorval[i][0]=pom;
        if(i+1<n)
        {
            xorval[i+1][0]=xorval[i][0];
        }
    }
    xorval[0][1]=0;
    pom=0;
    for(int i=1;i<n;i+=2)
    {
        pom^=x[i];
        xorval[i][1]=pom;
        if(i+1<n)
        {
            xorval[i+1][1]=xorval[i][1];
        }
    }
    while(t--)
    {
        int k,a,b;
        cin>>k>>a>>b;
        if(k==2)
        {
            if(n>5005)
            {
                a--;
                b--;
                int ans=0;
                if((b-a+1)%2==1)
                {
                    if(a%2==0)
                    {
                        int l=0,r=0;
                        int idx=a-2;
                        if(idx>=0)
                        {
                            l^=xorval[idx][0];
                        }
                        r=xorval[n-1][0];
                        r^=xorval[b][0];
                        ans=xorval[n-1][0];
                        ans^=l;
                        ans^=r;
                    }
                    else
                    {
                        int l=0,r=0;
                        int idx=a-2;
                        if(idx>=0)
                        {
                            l^=xorval[idx][1];
                        }
                        r=xorval[n-1][1];
                        r^=xorval[b][1];
                        ans=xorval[n-1][1];
                        ans^=l;
                        ans^=r;
                    }
                }
                cout<<ans<<endl;
            }
            else
            {
                a--;
                b--;
                int ans=0;
                if((b-a+1)%2==1)
                for(int i=a;i<=b;i+=2)
                {
                    ans^=x[i];
                }
                cout<<ans<<endl;
            }
        }
        else
        {
            a--;
            x[a]=b;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 460 KB Output is correct
13 Correct 9 ms 460 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 254 ms 8596 KB Output is correct
2 Correct 254 ms 8620 KB Output is correct
3 Correct 256 ms 8608 KB Output is correct
4 Correct 252 ms 8268 KB Output is correct
5 Correct 269 ms 8480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 460 KB Output is correct
13 Correct 9 ms 460 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 254 ms 8596 KB Output is correct
16 Correct 254 ms 8620 KB Output is correct
17 Correct 256 ms 8608 KB Output is correct
18 Correct 252 ms 8268 KB Output is correct
19 Correct 269 ms 8480 KB Output is correct
20 Incorrect 165 ms 8340 KB Output isn't correct
21 Halted 0 ms 0 KB -