# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
275487 |
2020-08-20T06:15:07 Z |
acm |
XORanges (eJOI19_xoranges) |
C++17 |
|
207 ms |
10616 KB |
#include <bits/stdc++.h>
#define speed \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define oprecision \
cout.precision(30); \
cerr.precision(7);
#define ll long long
#define ld long double
#define ss string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(n) for (int i = 1; i <= n; i++)
#define forlr(l, r) \
for (int i = l; (l > r ? i >= r : i <= r); (l > r ? i-- : i++))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define pc(x) __builtin_popcount(x)
#define pcll(x) __builtin_popcountll(x)
#define mp(x, y) make_pair(x, y)
#define F first
#define S second
using namespace std;
int n, q, a[200005], t[800005], e[800005];
void upd(int v, int l, int r, int x, int y) {
if (l == r) {
if (l & 1)
t[v] = y;
else
e[v] = y;
return;
}
int tm = (l + r) / 2;
if (x <= tm)
upd(v + v, l, tm, x, y);
else
upd(v + v + 1, tm + 1, r, x, y);
t[v] = (t[v + v] ^ t[v + v + 1]);
e[v] = (e[v + v] ^ e[v + v + 1]);
}
int get(int v, int l, int r, int x, int y, int z) {
if (r < x || y < l) return 0;
if (x <= l && r <= y) return (z ? t[v] : e[v]);
int tm = (l + r) / 2;
return (get(v + v, l, tm, x, y, z) ^ get(v + v + 1, tm + 1, r, x, y, z));
}
int main() {
speed;
oprecision;
// code
cin >> n >> q;
forn(n) {
int x;
cin >> x;
upd(1, 1, n, i, x);
}
while (q--) {
int type, l, r;
cin >> type >> l >> r;
if (type == 1) {
upd(1, 1, n, l, r);
}
if (type == 2) {
if ((r - l) % 2)
cout << 0 << "\n";
else
cout << ((l % 2) ? get(1, 1, n, l, r, 1) : get(1, 1, n, l, r, 0))
<< "\n";
}
}
// endl
#ifndef ONLINE_JUDGE
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
400 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
416 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
400 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
416 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
4 ms |
640 KB |
Output is correct |
12 |
Correct |
5 ms |
672 KB |
Output is correct |
13 |
Correct |
4 ms |
640 KB |
Output is correct |
14 |
Correct |
4 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
10488 KB |
Output is correct |
2 |
Correct |
199 ms |
10488 KB |
Output is correct |
3 |
Correct |
194 ms |
10616 KB |
Output is correct |
4 |
Correct |
169 ms |
10212 KB |
Output is correct |
5 |
Correct |
163 ms |
10104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
400 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
416 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
4 ms |
640 KB |
Output is correct |
12 |
Correct |
5 ms |
672 KB |
Output is correct |
13 |
Correct |
4 ms |
640 KB |
Output is correct |
14 |
Correct |
4 ms |
640 KB |
Output is correct |
15 |
Correct |
203 ms |
10488 KB |
Output is correct |
16 |
Correct |
199 ms |
10488 KB |
Output is correct |
17 |
Correct |
194 ms |
10616 KB |
Output is correct |
18 |
Correct |
169 ms |
10212 KB |
Output is correct |
19 |
Correct |
163 ms |
10104 KB |
Output is correct |
20 |
Correct |
185 ms |
10312 KB |
Output is correct |
21 |
Correct |
207 ms |
10180 KB |
Output is correct |
22 |
Correct |
206 ms |
10268 KB |
Output is correct |
23 |
Correct |
181 ms |
10104 KB |
Output is correct |
24 |
Correct |
192 ms |
10224 KB |
Output is correct |