# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
930157 |
2024-02-18T17:56:49 Z |
AmrT |
XORanges (eJOI19_xoranges) |
C++14 |
|
307 ms |
8964 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];
else if(len % 2 == 0)
cout << 0;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
287 ms |
6476 KB |
Output is correct |
2 |
Correct |
307 ms |
8864 KB |
Output is correct |
3 |
Correct |
285 ms |
8964 KB |
Output is correct |
4 |
Correct |
278 ms |
8784 KB |
Output is correct |
5 |
Correct |
271 ms |
8740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |