답안 #747572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747572 2023-05-24T10:43:46 Z AndrijaM XORanges (eJOI19_xoranges) C++14
75 / 100
319 ms 8396 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 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 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 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 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 6 ms 468 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 11 ms 464 KB Output is correct
14 Correct 11 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 301 ms 3788 KB Output is correct
2 Correct 299 ms 3796 KB Output is correct
3 Correct 296 ms 3732 KB Output is correct
4 Correct 319 ms 3820 KB Output is correct
5 Correct 299 ms 3788 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 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 6 ms 468 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 11 ms 464 KB Output is correct
14 Correct 11 ms 460 KB Output is correct
15 Correct 301 ms 3788 KB Output is correct
16 Correct 299 ms 3796 KB Output is correct
17 Correct 296 ms 3732 KB Output is correct
18 Correct 319 ms 3820 KB Output is correct
19 Correct 299 ms 3788 KB Output is correct
20 Incorrect 190 ms 8396 KB Output isn't correct
21 Halted 0 ms 0 KB -