Submission #747571

# Submission time Handle Problem Language Result Execution time Memory
747571 2023-05-24T10:41:38 Z AndrijaM XORanges (eJOI19_xoranges) C++14
38 / 100
329 ms 8680 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)
        {
            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--;
            x[a]=b;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 317 ms 7460 KB Output is correct
2 Correct 316 ms 8576 KB Output is correct
3 Correct 319 ms 8680 KB Output is correct
4 Correct 306 ms 8340 KB Output is correct
5 Correct 329 ms 8320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -