Submission #930152

# Submission time Handle Problem Language Result Execution time Memory
930152 2024-02-18T17:48:45 Z AmrT XORanges (eJOI19_xoranges) C++14
0 / 100
182 ms 8924 KB
#include <bits/stdc++.h>
#define lop(i,a,b) for(ll i = a; i < b; i++)
#define alop(i,v) for(auto &i: v)
#define in(v) for(auto &i: v) cin >> i;
#define ll long long
//#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(dp, x) memset(dp, x, sizeof(dp))
using namespace std;
const ll mod = 1e9 + 7;


int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    ll n, q; cin >> n >> q;
    ll arr[n]; in(arr);
    ll pre0[n] = {}, pre1[n] = {};
    pre0[0] = pre0[1] = arr[0], pre1[1] = arr[1];
    for(int i = 2; i < n; i++){
        if(i % 2 == 0) 
            pre0[i] ^= arr[i];
        else 
            pre1[i] ^= arr[i];
        pre0[i] ^= pre0[i - 1];
        pre1[i] ^= pre1[i - 1];
    }

    while(q--){
        ll t, l, r; cin >> t >> l >> r;
        l--, r--;

        ll len = r - l + 1;
        if(len == 1){
            cout << arr[l];
            continue;   
        }
        else if(len % 2 == 0){
            cout << 0;
            continue;
        }
        else{
            if(l % 2 == 0)
                cout << (pre1[r] ^ pre1[l]);
            else
                cout << (pre0[r] ^ pre0[l]);
        }
        cout << endl;
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 8924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -