Submission #997384

# Submission time Handle Problem Language Result Execution time Memory
997384 2024-06-12T08:24:55 Z vjudge1 XORanges (eJOI19_xoranges) C++17
100 / 100
88 ms 16728 KB
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;
const int N = 500001;

using namespace std;
using namespace __gnu_pbds;

ll tt, n, m, k, a, b, c, d, e, f[N], p[N], l, r, t[N * 4][2];

void build (ll tl = 1, ll tr = n, ll v = 1){
	if (tl == tr){
		if (tl % 2){
			t[v][1] = p[tl];
			t[v][0] = 0;
		}
		else{
			t[v][0] = p[tl];
			t[v][1] = 0;
		}
		return;
	}
	ll tm = (tl + tr) / 2;
	build (tl, tm, v + v);
	build (tm + 1, tr, v + v + 1);
	t[v][1] = (t[v + v][1] ^ t[v + v + 1][1]);
	t[v][0] = (t[v + v][0] ^ t[v + v + 1][0]);
}

void upd (ll idx, ll val, ll tl = 1, ll tr = n, ll v = 1){
	if (tr < idx || tl > idx){
		return;
	}
	if (tl == tr && tl == idx){
		if (tl % 2){
			t[v][1] = val;
			t[v][0] = 0;
		}
		else{
			t[v][0] = val;
			t[v][1] = 0;
		}
		return;
	}
	ll tm = (tl + tr) / 2;
	upd (idx, val, tl, tm, v + v);
	upd (idx, val, tm + 1, tr, v + v + 1);
	t[v][1] = (t[v + v][1] ^ t[v + v + 1][1]);
	t[v][0] = (t[v + v][0] ^ t[v + v + 1][0]);
}

ll get (ll l, ll r, ll tp, ll tl = 1, ll tr = n, ll v = 1){
	if (l <= tl && tr <= r){
		return t[v][tp];
	}
	if (tr < l || tl > r){
		return 0;
	}
	ll tm = (tl + tr) / 2;
	return (get (l, r, tp, tl, tm, v + v) ^ get (l, r, tp, tm + 1, tr, v + v + 1));
}

signed main (){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		cin >> p[i];
	}
	build ();
	while (m--){
		ll tp;
		cin >> tp;
		if (tp == 1){
			cin >> a >> b;
			upd (a, b);
		}
		else{
			cin >> a >> b;
			if ((b - a + 1) % 2){
				cout << get (a, b, a % 2) << '\n';
			}
			else{
				cout << "0\n";
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2520 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2520 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 3 ms 4680 KB Output is correct
12 Correct 2 ms 4700 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 2 ms 4668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 16720 KB Output is correct
2 Correct 83 ms 16728 KB Output is correct
3 Correct 85 ms 16720 KB Output is correct
4 Correct 67 ms 16376 KB Output is correct
5 Correct 71 ms 16468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2520 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 3 ms 4680 KB Output is correct
12 Correct 2 ms 4700 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 2 ms 4668 KB Output is correct
15 Correct 81 ms 16720 KB Output is correct
16 Correct 83 ms 16728 KB Output is correct
17 Correct 85 ms 16720 KB Output is correct
18 Correct 67 ms 16376 KB Output is correct
19 Correct 71 ms 16468 KB Output is correct
20 Correct 88 ms 16456 KB Output is correct
21 Correct 82 ms 16576 KB Output is correct
22 Correct 82 ms 16440 KB Output is correct
23 Correct 79 ms 16344 KB Output is correct
24 Correct 76 ms 16464 KB Output is correct