#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,t;
cin>>n>>t;
int x[n];
for(int i=0;i<n;i++)
{
cin>>x[i];
}
int xorval[n][2];
int pom=0;
for(int i=0;i<n;i+=2)
{
pom^=x[i];
xorval[i][0]=pom;
if(i+1<n)
{
xorval[i+1][0]=xorval[i][0];
}
}
xorval[0][1]=0;
pom=0;
for(int i=1;i<n;i+=2)
{
pom^=x[i];
xorval[i][1]=pom;
if(i+1<n)
{
xorval[i+1][1]=xorval[i][1];
}
}
while(t--)
{
int k,a,b;
cin>>k>>a>>b;
if(k==2)
{
if(n>5005)
{
a--;
b--;
int ans=0;
if((b-a+1)%2==1)
{
if(a%2==0)
{
int l=0,r=0;
int idx=a-2;
if(idx>=0)
{
l^=xorval[idx][0];
}
r=xorval[n-1][0];
r^=xorval[b][0];
ans=xorval[n-1][0];
ans^=l;
ans^=r;
}
else
{
int l=0,r=0;
int idx=a-2;
if(idx>=0)
{
l^=xorval[idx][1];
}
r=xorval[n-1][1];
r^=xorval[b][1];
ans=xorval[n-1][1];
ans^=l;
ans^=r;
}
}
cout<<ans<<endl;
}
else
{
a--;
b--;
int ans=0;
if((b-a+1)%2==1)
for(int i=a;i<=b;i+=2)
{
ans^=x[i];
}
cout<<ans<<endl;
}
}
else
{
a--;
x[a]=b;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
7 ms |
364 KB |
Output is correct |
12 |
Correct |
7 ms |
340 KB |
Output is correct |
13 |
Correct |
11 ms |
372 KB |
Output is correct |
14 |
Correct |
15 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
389 ms |
3704 KB |
Output is correct |
2 |
Correct |
399 ms |
3828 KB |
Output is correct |
3 |
Correct |
393 ms |
3720 KB |
Output is correct |
4 |
Correct |
369 ms |
3796 KB |
Output is correct |
5 |
Correct |
403 ms |
3788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
7 ms |
364 KB |
Output is correct |
12 |
Correct |
7 ms |
340 KB |
Output is correct |
13 |
Correct |
11 ms |
372 KB |
Output is correct |
14 |
Correct |
15 ms |
340 KB |
Output is correct |
15 |
Correct |
389 ms |
3704 KB |
Output is correct |
16 |
Correct |
399 ms |
3828 KB |
Output is correct |
17 |
Correct |
393 ms |
3720 KB |
Output is correct |
18 |
Correct |
369 ms |
3796 KB |
Output is correct |
19 |
Correct |
403 ms |
3788 KB |
Output is correct |
20 |
Incorrect |
298 ms |
3184 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |