#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 == 1)
cout << (pre1[r] ^ (l ? pre1[l - 1] : 0));
else
cout << (pre0[r] ^ (l ? pre0[l - 1] : 0));
}
cout << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
174 ms |
6220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |