#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<long long>
#define MOD 1000000007
#define endl '\n'
typedef long long ll;
void print(vi v){
cout<<"Contents of vector:\n";
for(auto x : v) cout<<x<<" ";
cout<<endl<<endl;
}
void solve(){
int n, q; cin>>n>>q;
int ar[n], pref[n+1];
for(int i = 0; i<n; i++) cin>>ar[i];
pref[0] = 0;
pref[1] = ar[0];
for(int i = 2; i<=n; i++) {
pref[i] = pref[i-1] ^ ar[i-1];
//else pref[1] = ar[0] ^ ar[1];
}
/*cout<<"Prefs: "<<endl;
for(int i = 0; i<n+1; i++) cout<<pref[i]<<" ";
cout<<endl<<endl;*/
for(int i = 0; i<q; i++){
int type; cin>>type;
if(type == 1){
int ind, value; cin>>ind>>value;
ar[ind-1] = value;
/*cout<<"array: "<<endl;
for(int i = 0; i<=n; i++) cout<<ar[i]<<" ";
cout<<endl<<endl;*/
pref[0] = 0;
pref[1] = ar[0];
for(int i = 2; i<=n; i++) {
pref[i] = pref[i-1] ^ ar[i-1];
//else pref[1] = ar[0] ^ ar[1];
}
/*cout<<"Prefs: "<<endl;
for(int i = 0; i<=n; i++) cout<<pref[i]<<" ";
cout<<endl<<endl;*/
} else {
int from, to; cin>>from>>to;
/*int ans = pref[to] ^ pref[from-1];
//cout<<ans<<endl;
for(int j = 1; j<to; j++){ ///j = range(1 = pair, 2 = three)
for(int k = from-1; k<to-j; k++) {
//cout<<"Adding "<<k+j+1<<" and "<<k<<endl;
int xo = pref[k+j+1] ^ pref[k];
// cout<<"Got: "<<xo<<endl;
ans ^= xo;
}
}
cout<<ans<<endl;*/
map<int, int> m;
for(int i = from; i<=to; i++){
m[ar[i-1]] += i * (to-i+1);
//m[ar[i-1]]--;
}
/*cout<<"Map: "<<endl;
for(auto x : m){
cout<<x.first<<" : "<<x.second<<endl;
}*/
if(m.size() == 1){
for(auto x : m){
cout<<x.first<<endl;
}
continue;
}
int ans = 0;
for(auto x : m){
if(x.second % 2){
ans ^= x.first;
}
}
cout<<ans<<endl;
}
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
//ifstream cin("input.txt"); ofstream cout("output.txt");///cia failai
//int T; cin>>T;
int T = 1;
for(int it = 1; it<=T; it++){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
11308 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |