//don't copy pls)
/*TAAK ZDES NADO RECURSIU PISAT*/
//I'm not in the danger i am the DANGER
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int,int>
#define sigma signed
using namespace std;
using namespace __gnu_pbds;
const int N = 3e5 + 5;
int mod = 1e9 + 7;
const int INF = 1e18;
int n,q,a[N],p[N],ans[N],t[3][N];
void build(int v = 1 , int tl = 1 , int tr = n){
if(tl == tr){
if(tl % 2){
t[1][v] = a[tl];
}
else{
t[0][v] = a[tl];
}
return;
}
int tm = tl + tr >> 1;
build(v * 2 , tl , tm);
build(v * 2 + 1 , tm + 1 , tr);
t[0][v] = t[0][v * 2] ^ t[0][v * 2 + 1];
t[1][v] = t[1][v * 2] ^ t[1][v * 2 + 1];
}
void upd(int pos , int x , int v = 1 , int tl = 1 , int tr = n){
if(tl > pos || tr < pos) return;
if(tl == pos && tr == pos){
t[pos % 2][v] = x;
return;
}
int tm = tl + tr >> 1;
upd(pos , x , v * 2 , tl , tm);
upd(pos , x , v * 2 + 1 , tm + 1 , tr);
t[pos % 2][v] = t[pos % 2][v * 2] ^ t[pos % 2][v * 2 + 1];
}
int get(int id , int l , int r , int v = 1 , int tl = 1 , int tr = n){
if(tl > r || tr < l) return 0;
if(tl >= l && tr <= r) return t[id][v];
int tm = tl + tr >> 1;
return get(id , l , r , v * 2 , tl , tm) ^ get(id , l , r , v * 2 + 1 , tm + 1 , tr);
}
void Gold(){
cin >> n >> q;
for(int i = 1 ; i <= n ; i++){
cin >> a[i];
}
build();
while(q--){
int tp;
cin >> tp;
if(tp == 1){
int x,y;
cin >> x >> y;
a[x] = y;
upd(x , y);
}
else{
int l,r;
cin >> l >> r;
// if(r - l + 1 == 1){
// cout << a[l] << '\n';
// continue;
// }
// if((r - l + 1) % 2 == 0){
// cout << (get(0 , l , r) ^ get(1 , l , r)) << '\n';
// continue;
// }
// cout << get(1 , l , r) << '\n';
// continue;
int x = 0;
map <int,int> mp;
for(int i = l ; i <= r ; i++){
ans[i] = 0;
}
for(int j = 1 ; j <= r - l + 1 ; j++){
for(int i = l + j - 1 ; i <= r ; i++){
x ^= get(1 , i - j + 1 , i) ^ get(0 , i - j + 1 , i);
for(int k = i - j + 1 ; k <= i ; k++){
mp[a[k]]++;
}
}
}
// for(auto it : mp){
// cout << it.F << ' ' << it.S << '\n';
// }
cout << x << '\n';
}
}
}
sigma main(){
//freopen("txt.in","r",stdin);
//freopen("txt.out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
srand(time(0));
int TT = 1;
// cin >> TT;
for(int i = 1 ; i <= TT ; i++){
//cout << "Case " << i << ": ";
Gold();
}
}
Compilation message
xoranges.cpp: In function 'void build(long long int, long long int, long long int)':
xoranges.cpp:31:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
31 | int tm = tl + tr >> 1;
| ~~~^~~~
xoranges.cpp: In function 'void upd(long long int, long long int, long long int, long long int, long long int)':
xoranges.cpp:43:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
43 | int tm = tl + tr >> 1;
| ~~~^~~~
xoranges.cpp: In function 'long long int get(long long int, long long int, long long int, long long int, long long int, long long int)':
xoranges.cpp:51:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
51 | int tm = tl + tr >> 1;
| ~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
6488 KB |
Output is correct |
2 |
Correct |
15 ms |
6492 KB |
Output is correct |
3 |
Correct |
14 ms |
6492 KB |
Output is correct |
4 |
Correct |
87 ms |
6600 KB |
Output is correct |
5 |
Correct |
107 ms |
6600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1040 ms |
6624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
6488 KB |
Output is correct |
2 |
Correct |
15 ms |
6492 KB |
Output is correct |
3 |
Correct |
14 ms |
6492 KB |
Output is correct |
4 |
Correct |
87 ms |
6600 KB |
Output is correct |
5 |
Correct |
107 ms |
6600 KB |
Output is correct |
6 |
Execution timed out |
1040 ms |
6624 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1043 ms |
13388 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
6488 KB |
Output is correct |
2 |
Correct |
15 ms |
6492 KB |
Output is correct |
3 |
Correct |
14 ms |
6492 KB |
Output is correct |
4 |
Correct |
87 ms |
6600 KB |
Output is correct |
5 |
Correct |
107 ms |
6600 KB |
Output is correct |
6 |
Execution timed out |
1040 ms |
6624 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |