Submission #1048969

# Submission time Handle Problem Language Result Execution time Memory
1048969 2024-08-08T11:44:26 Z Nickpapadak XORanges (eJOI19_xoranges) C++14
38 / 100
52 ms 9556 KB
#include<bits/stdc++.h>
using namespace std;
const unsigned int MAXN = 2e+5 + 10;
bool mp[MAXN];
int pf[MAXN], pf1[MAXN],pf2[MAXN], a[MAXN];
int N, Q;
int main(){
    scanf("%d%d",&N,&Q);
    // mp.resize(N+1, 0);
    for(int i = 1; i<=N;++i){
        scanf("%d",&a[i]);
        pf[i] = pf[i-1] ^ a[i];
        // mp[i] = 0;
    }
    pf1[1] = a[1];
    for(int i = 3; i<=N; i+=2){
        pf1[i] = pf1[i-2] ^ a[i];
    }
    for(int i = 2; i<=N; i+=2){
        pf2[i] = pf2[i-2] ^ a[i];
    }
    while(Q--){
        int s,b, type;
        scanf("%d%d%d", &type, &s, &b);
        if(type == 2){
            int ans = 0;
            // for(int i = 1; i <= b-s+1; ++i){
                // for(int j = s; j+i-1 <= b;++j){
                    // ans ^= (pf[j+i-1] ^ pf[j-1]);
                //     // changemp(j+i-1);
                //     // changemp(j+i-1);
                //     for(int k = j; k <= j+i-1; ++k) mp[k] = !mp[k];
                //     // mp[j+i-1] = !mp[j+i-1];
                //     // mp[j-1] = !mp[j-1];
                // }
            // }
            if((b-s+1) % 2 == 1){
                if(s % 2 == 1) ans = pf1[b] ^ pf1[max(s-2,0)];
                else           ans = pf2[b] ^ pf2[max(s-2,0)];
            }
            // for(int i = 1; i<=N;++i){
                // printf("[%d]", i);
            // }
            // printf("\n");
            // for(int i = 1; i<=N;++i){
                // printf(" %d ", mp[i]);
                // mp[i] = 0;
            // }
            // printf("\n");
            printf("%d\n", ans);
        }
        // }else{
        //     a[s] = b;
        //     for(int i = s; i<=N;++i){
        //         pf[i] = pf[i-1] ^ a[i];
        //     }
        // }
    }
    return 0;
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d%d",&N,&Q);
      |     ~~~~~^~~~~~~~~~~~~~
xoranges.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
xoranges.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%d%d%d", &type, &s, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 49 ms 4588 KB Output is correct
2 Correct 52 ms 9556 KB Output is correct
3 Correct 51 ms 9556 KB Output is correct
4 Correct 48 ms 9044 KB Output is correct
5 Correct 49 ms 9104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -