// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
string bin(int x){
string s;
while(x!=0){
if(x%2==1)s.push_back('1');
else s.push_back('0');
x/=2;
}
while(s.size()!=30){
s.push_back('0');
}
reverse(s.begin(),s.end());
return s;
}
string xr(string a, string b){
string s;
for(int i=0;i<30;i++){
if(a[i]==b[i])s.push_back('0');
else s.push_back('1');
}
return s;
}
long long nib(string s){
long long r=0,m;
reverse(s.begin(),s.end());
m=1;
for(int i=0;i<30;i++){
r+=(s[i]-'0')*m;
m*=2;
}
return r;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
int n,q;
cin >> n >> q;
vector<string> s(n);
for(int i=0;i<n;i++){
int a;
cin >> a;
s[i]=bin(a);
}
vector<vector<int> > v(n+1,vector<int>(n+1));
for(int i=1;i<n+1;i++){
for(int j=1;j<i+1;j++){
for(int k=1;k<i+1;k++){
v[i][j]+=min(j,min(i-j+1,min(i-k+1,k)));
v[i][j]=v[i][j]%2;
}
}
}
for(int z=0;z<q;z++){
vector<int> x;
int a;
cin >> a;
if(a==1){
int b;
cin >> a >> b;
s[a-1]=bin(b);
}else{
int b;
cin >> a >> b;
for(size_t i=1;i<=b-a+1;i++){
if(v[b-a+1][i]%2==1)x.push_back(a+i-2);
}
string e;
if (x.size()>1){
string aaa=s[x[0]],bbb=s[x[1]];
e=xr(aaa,bbb);
for(size_t i=2;i<x.size();i++){
e=xr(e,s[x[i]]);
}
}else e=s[x[0]];
cout << nib(e) << endl;
}
}
}
Compilation message
xoranges.cpp: In function 'int main()':
xoranges.cpp:71:20: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
71 | for(size_t i=1;i<=b-a+1;i++){
| ~^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
69 ms |
2644 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
92 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |