# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
739928 |
2023-05-11T16:31:53 Z |
pera |
XORanges (eJOI19_xoranges) |
C++14 |
|
635 ms |
47608 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define int ll
const ll mod = 1e9 + 7 , N = 2e5 + 1;
int n , q;
vector<int> a(N);
vector<vector<int>> t(4 * N , vector<int>(2));
int comb(int u , int v){
return u ^ v;
}
void up(int v , int l , int r , int p , int val , int c){
if(l == r){
t[v][c] = val;
}else{
int m = (l + r) / 2;
if(p <= m) up(v * 2 , l , m , p , val , c);
else up(v * 2 + 1 , m + 1, r , p , val , c);
t[v][c] = comb(t[v * 2][c] , t[v * 2 + 1][c]);
}
}
int xr(int v , int l , int r , int L , int R , int c){
if(l > r || l > R || r < L) return 0;
if(l >= L && r <= R){
return t[v][c];
}
int m = (l + r) / 2;
return comb(xr(v * 2 , l , m , L , R , c) , xr(v * 2 + 1 , m + 1 , r , L , R , c));
}
main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin >> n >> q;
for(int i = 1;i <= n;i ++){
cin >> a[i];
up(1 , 1 , n , (i + 1) / 2 , a[i] , i & 1);
}
// cout << xr(1 , 1 , n , 2 , 2 , 0) << endl;
while(q --){
int T , x , y;cin >> T >> x >> y;
if(T == 1){
up(1 , 1 , n , (x + 1) / 2 , y , x & 1);
}else{
int lo = 0 , ro = 0 , le = 0 , re = 0;
if(x & 1) lo = (x + 1) / 2;
else lo = x / 2 + 1;
if(y & 1) ro = (y + 1) / 2;
else ro = y / 2;
le = (x + 1) / 2 , re = y / 2;
int X1 = xr(1 , 1 , n , lo , ro , 1) , X2 = xr(1 , 1 , n , le , re , 0) , X = 0;
/*cout << X1 << " " << X2 << endl;
cout << "---------------" << endl;
cout << lo << " " << ro << endl;
cout << le << " " << re << endl;
cout << "---------------" << endl;*/
cout << ((y - x + 1) & 1 == x & 1 ? X1 : X2) << endl;
}
}
}
Compilation message
xoranges.cpp:42:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
42 | main(){
| ^~~~
xoranges.cpp: In function 'int main()':
xoranges.cpp:68:29: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
68 | cout << ((y - x + 1) & 1 == x & 1 ? X1 : X2) << endl;
| ~~^~~~
xoranges.cpp:62:79: warning: unused variable 'X' [-Wunused-variable]
62 | int X1 = xr(1 , 1 , n , lo , ro , 1) , X2 = xr(1 , 1 , n , le , re , 0) , X = 0;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
45596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
45676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
45596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
635 ms |
47608 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
45596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |