#include <bits/stdc++.h>
/// author: LilPluton auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
using namespace std;
#define int long long
const int N = 3e5 + 5;
const int INF = 1e18;
const int md = 1e9 + 7;
void show(vector<int> &a)
{
for(auto i : a)
cout << i << ' ';
cout << endl;
}
int n, q;
struct tree
{
int st[N * 4];
tree()
{
memset(st, 0, sizeof(st));
}
void upd(int in,int l,int r,int pos,int val)
{
if(l == r)
{
st[in] = val;
return;
}
int mid = (l + r) >> 1;
if(pos <= mid) upd(in * 2, l, mid, pos, val);
else upd(in * 2 + 1, mid + 1, r, pos, val);
st[in] = st[in * 2] ^ st[in * 2 + 1];
}
int getans(int in,int tl,int tr,int l,int r)
{
if(tr < l || tl > r) return 0;
if(l <= tl && tr <= r) return st[in];
int mid = (tl + tr) / 2;
return getans(in * 2, tl, mid, l, r) ^ getans(in * 2 + 1, mid + 1, tr, l, r);
}
} seg1, seg2;
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> q;
for(int i = 1, x; i <= n; ++i)
{
cin >> x;
if(i & 1) seg1.upd(1,1,n,i / 2 + 1, x);
else seg2.upd(1,1,n,i/2,x);
}
while(q--)
{
int t,l,r;
cin >> t >> l >> r;
if(t == 1)
{
if(l & 1) seg1.upd(1,1,n,l / 2 + 1, r);
else seg2.upd(1,1,n,l / 2, r);
}
else
{
int id = (r - l + 1);
if(id & 1)
{
if(l & 1) cout << seg1.getans(1,1,n,l / 2 + 1, l / 2 + 1 + id / 2) << endl;
else cout << seg2.getans(1,1,n,l / 2, l / 2 + id / 2) << endl;
}
else
{
cout << 0 << endl;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
19032 KB |
Output is correct |
2 |
Correct |
2 ms |
19048 KB |
Output is correct |
3 |
Correct |
2 ms |
19036 KB |
Output is correct |
4 |
Correct |
2 ms |
19036 KB |
Output is correct |
5 |
Correct |
2 ms |
19036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
19032 KB |
Output is correct |
2 |
Correct |
3 ms |
19036 KB |
Output is correct |
3 |
Correct |
3 ms |
19036 KB |
Output is correct |
4 |
Correct |
3 ms |
19036 KB |
Output is correct |
5 |
Correct |
3 ms |
19036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
19032 KB |
Output is correct |
2 |
Correct |
2 ms |
19048 KB |
Output is correct |
3 |
Correct |
2 ms |
19036 KB |
Output is correct |
4 |
Correct |
2 ms |
19036 KB |
Output is correct |
5 |
Correct |
2 ms |
19036 KB |
Output is correct |
6 |
Correct |
3 ms |
19032 KB |
Output is correct |
7 |
Correct |
3 ms |
19036 KB |
Output is correct |
8 |
Correct |
3 ms |
19036 KB |
Output is correct |
9 |
Correct |
3 ms |
19036 KB |
Output is correct |
10 |
Correct |
3 ms |
19036 KB |
Output is correct |
11 |
Correct |
6 ms |
19288 KB |
Output is correct |
12 |
Correct |
6 ms |
19292 KB |
Output is correct |
13 |
Correct |
9 ms |
19292 KB |
Output is correct |
14 |
Correct |
9 ms |
19292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
295 ms |
20324 KB |
Output is correct |
2 |
Correct |
290 ms |
25224 KB |
Output is correct |
3 |
Correct |
285 ms |
25116 KB |
Output is correct |
4 |
Correct |
289 ms |
24912 KB |
Output is correct |
5 |
Correct |
283 ms |
24764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
19032 KB |
Output is correct |
2 |
Correct |
2 ms |
19048 KB |
Output is correct |
3 |
Correct |
2 ms |
19036 KB |
Output is correct |
4 |
Correct |
2 ms |
19036 KB |
Output is correct |
5 |
Correct |
2 ms |
19036 KB |
Output is correct |
6 |
Correct |
3 ms |
19032 KB |
Output is correct |
7 |
Correct |
3 ms |
19036 KB |
Output is correct |
8 |
Correct |
3 ms |
19036 KB |
Output is correct |
9 |
Correct |
3 ms |
19036 KB |
Output is correct |
10 |
Correct |
3 ms |
19036 KB |
Output is correct |
11 |
Correct |
6 ms |
19288 KB |
Output is correct |
12 |
Correct |
6 ms |
19292 KB |
Output is correct |
13 |
Correct |
9 ms |
19292 KB |
Output is correct |
14 |
Correct |
9 ms |
19292 KB |
Output is correct |
15 |
Correct |
295 ms |
20324 KB |
Output is correct |
16 |
Correct |
290 ms |
25224 KB |
Output is correct |
17 |
Correct |
285 ms |
25116 KB |
Output is correct |
18 |
Correct |
289 ms |
24912 KB |
Output is correct |
19 |
Correct |
283 ms |
24764 KB |
Output is correct |
20 |
Correct |
187 ms |
24780 KB |
Output is correct |
21 |
Correct |
183 ms |
24912 KB |
Output is correct |
22 |
Correct |
189 ms |
24960 KB |
Output is correct |
23 |
Correct |
278 ms |
24912 KB |
Output is correct |
24 |
Correct |
267 ms |
24880 KB |
Output is correct |