#include <bits/stdc++.h>
using namespace std;
int t[1000*1000+10];
const int SS = 1024*1024;
int drzewo[SS*2+10];
int drzewo2[SS*2+10];
void Insert(int x, int ind)
{
if(ind % 2 == 0)
return;
ind += SS;
drzewo[ind] = x;
ind = (ind>>1);
while(ind > 0)
{
drzewo[ind] = drzewo[(ind<<1)] ^ drzewo[(ind << 1) + 1];
ind = (ind>>1);
}
}
int Query(int pocz, int kon)
{
pocz += SS -1, kon += SS + 1;
int wynik = 0;
while((pocz>>1) != (kon>>1))
{
if(pocz % 2 == 0)
wynik = wynik ^ drzewo[pocz+1];
if(kon%2 == 1)
wynik = wynik ^ drzewo[kon-1];
pocz = (pocz>>1), kon = (kon>>1);
}
return wynik;
}
void Insert2(int x, int ind)
{
if(ind % 2 == 1)
return;
ind += SS;
drzewo2[ind] = x;
ind = (ind>>1);
while(ind > 0)
{
drzewo2[ind] = drzewo2[(ind<<1)] ^ drzewo2[(ind << 1) + 1];
ind = (ind>>1);
}
}
int Query2(int pocz, int kon)
{
pocz += SS -1, kon += SS + 1;
int wynik = 0;
while((pocz>>1) != (kon>>1))
{
if(pocz % 2 == 0)
wynik = wynik ^ drzewo2[pocz+1];
if(kon%2 == 1)
wynik = wynik ^ drzewo2[kon-1];
pocz = (pocz>>1), kon = (kon>>1);
}
return wynik;
}
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
int n;
cin >> n;
int q;
cin >> q;
for(int i = 1; i <= n; i++)
{
cin >> t[i];
Insert(t[i],i);
Insert2(t[i],i);
}
for(int i = 1; i <= q; i++)
{
int a,b,c;
cin >> a >> b >> c;
if(a == 2)
{
if((b-c + 1) % 2 == 0)
cout << 0 << "\n";
else
{
if(b % 2 == 0)
cout << Query2(b,c) << "\n";
else
cout << Query(b,c) << "\n";
}
}
else
{
Insert2(c,b);
Insert(c,b);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
3 ms |
768 KB |
Output is correct |
12 |
Correct |
4 ms |
768 KB |
Output is correct |
13 |
Correct |
3 ms |
768 KB |
Output is correct |
14 |
Correct |
4 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
10488 KB |
Output is correct |
2 |
Correct |
137 ms |
10488 KB |
Output is correct |
3 |
Correct |
143 ms |
10404 KB |
Output is correct |
4 |
Correct |
130 ms |
10148 KB |
Output is correct |
5 |
Correct |
139 ms |
10104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
3 ms |
768 KB |
Output is correct |
12 |
Correct |
4 ms |
768 KB |
Output is correct |
13 |
Correct |
3 ms |
768 KB |
Output is correct |
14 |
Correct |
4 ms |
768 KB |
Output is correct |
15 |
Correct |
153 ms |
10488 KB |
Output is correct |
16 |
Correct |
137 ms |
10488 KB |
Output is correct |
17 |
Correct |
143 ms |
10404 KB |
Output is correct |
18 |
Correct |
130 ms |
10148 KB |
Output is correct |
19 |
Correct |
139 ms |
10104 KB |
Output is correct |
20 |
Correct |
150 ms |
10328 KB |
Output is correct |
21 |
Correct |
139 ms |
10232 KB |
Output is correct |
22 |
Correct |
148 ms |
10248 KB |
Output is correct |
23 |
Correct |
138 ms |
10060 KB |
Output is correct |
24 |
Correct |
150 ms |
10104 KB |
Output is correct |