#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()
#define x first
#define y second
#define int long long
#define nl "\n"
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;
const int N = (int)3e5 + 7;
const int M = (int)7e6 + 7;
const ll MOD = (ll)1e9 + 7;
const int inf = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
pii dir[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
int n, q, a[N], p[N][2];
void solve() {
cin >> n >> q;
for(int i = 1; i <= n; ++i) cin >> a[i];
p[1][0] = a[1];
for(int i = 3; i <= n; ++i) p[i][0] = (p[i-2][0] ^ a[i]);
p[2][1] = a[2];
for(int i = 4; i <= n; ++i) p[i][1] = (p[i-2][1] ^ a[i]);
while(q--) {
char c;
cin >> c;
int l, r;
cin >> l >> r;
if(c == '1') {
a[l] = r;
p[1][0] = a[1];
for(int i = 3; i <= n; ++i) p[i][0] = (p[i-2][0] ^ a[i]);
p[2][1] = a[2];
for(int i = 4; i <= n; ++i) p[i][1] = (p[i-2][1] ^ a[i]);
continue;
}
int res = 0;
if(((r - l + 1) & 1) == 0) {
cout << "0\n";
continue;
}
if(l & 1) res = (p[r][0] ^ (l == 1 ? 0 : p[l-2][0]));
else res = (p[r][1] ^ p[l-2][1]);
cout << res << nl;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int test = 1;
//cin >> test;
for(int i = 1; i <= test; i++) {
//cout << "Case " << i << ":\n";
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
40 ms |
448 KB |
Output is correct |
12 |
Correct |
41 ms |
552 KB |
Output is correct |
13 |
Correct |
6 ms |
456 KB |
Output is correct |
14 |
Correct |
6 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
6192 KB |
Output is correct |
2 |
Correct |
89 ms |
6096 KB |
Output is correct |
3 |
Correct |
85 ms |
6156 KB |
Output is correct |
4 |
Correct |
72 ms |
6084 KB |
Output is correct |
5 |
Correct |
79 ms |
6328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
40 ms |
448 KB |
Output is correct |
12 |
Correct |
41 ms |
552 KB |
Output is correct |
13 |
Correct |
6 ms |
456 KB |
Output is correct |
14 |
Correct |
6 ms |
460 KB |
Output is correct |
15 |
Correct |
92 ms |
6192 KB |
Output is correct |
16 |
Correct |
89 ms |
6096 KB |
Output is correct |
17 |
Correct |
85 ms |
6156 KB |
Output is correct |
18 |
Correct |
72 ms |
6084 KB |
Output is correct |
19 |
Correct |
79 ms |
6328 KB |
Output is correct |
20 |
Execution timed out |
1091 ms |
5000 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |