#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, q;
vector<int> numbers;
vector<int> prefix;
void update() {
int pos, val;
cin >> pos >> val;
numbers[pos] = val;
prefix[1] = numbers[1];
for(int i = 2; i <= n; ++i) {
prefix[i] = prefix[i - 2] ^ numbers[i];
}
}
void query() {
int l, r;
cin >> l >> r;
if((r - l + 1) % 2 == 0) {
cout << "0\n";
return;
}
cout << (prefix[r] ^ prefix[l] ^ numbers[l]) << "\n";
}
void solve() {
cin >> n >> q;
numbers.assign(1 + n, 0);
prefix.assign(1 + n, 0);
for(int i = 1; i <= n; ++i) {
cin >> numbers[i];
if(i == 1) prefix[i] = numbers[i];
else prefix[i] = prefix[i - 2] ^ numbers[i];
}
while(q--) {
int type = 0;
cin >> type;
if(type == 1) update();
else query();
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
22 ms |
332 KB |
Output is correct |
12 |
Correct |
24 ms |
480 KB |
Output is correct |
13 |
Correct |
5 ms |
448 KB |
Output is correct |
14 |
Correct |
5 ms |
456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
109 ms |
4004 KB |
Output is correct |
2 |
Correct |
103 ms |
4164 KB |
Output is correct |
3 |
Correct |
111 ms |
4048 KB |
Output is correct |
4 |
Correct |
112 ms |
3792 KB |
Output is correct |
5 |
Correct |
107 ms |
3880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
22 ms |
332 KB |
Output is correct |
12 |
Correct |
24 ms |
480 KB |
Output is correct |
13 |
Correct |
5 ms |
448 KB |
Output is correct |
14 |
Correct |
5 ms |
456 KB |
Output is correct |
15 |
Correct |
109 ms |
4004 KB |
Output is correct |
16 |
Correct |
103 ms |
4164 KB |
Output is correct |
17 |
Correct |
111 ms |
4048 KB |
Output is correct |
18 |
Correct |
112 ms |
3792 KB |
Output is correct |
19 |
Correct |
107 ms |
3880 KB |
Output is correct |
20 |
Execution timed out |
1095 ms |
4184 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |