Submission #638752

# Submission time Handle Problem Language Result Execution time Memory
638752 2022-09-07T09:30:14 Z Koful123 XORanges (eJOI19_xoranges) C++17
100 / 100
97 ms 10788 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

struct Fenwick{
	int n;
	vector<int> fw;
	Fenwick(int _n){
		fw.assign(n = _n+1,0);
	}
	void upd(int pos,int val){
		while(pos <= n){
			fw[pos] ^= val;
			pos += (pos & -pos);
		}
	}
	int get(int pos){
		int res = 0;
		while(pos > 0){
			res ^= fw[pos];	
			pos -= (pos & -pos);
		}
		return res;
	}
};

void solve(){

	int n,q;
	cin >> n >> q;

	Fenwick odd(n),even(n);
	vector<int> v(n+1);
	for(int i=1;i<=n;i++){
		cin >> v[i];
		if(i % 2) odd.upd(i,v[i]);
		else even.upd(i,v[i]);
	}

	for(int i=0;i<q;i++){
		int ty,a,b;
		cin >> ty >> a >> b;	
		if(ty == 1){
			if(a % 2) odd.upd(a,v[a]),odd.upd(a,b);
			else even.upd(a,v[a]),even.upd(a,b);
			v[a] = b;
		}
		else{
			if((b-a+1) % 2){
				if(a % 2) cout << (odd.get(b) ^ odd.get(a-2)) << endl;
				else cout << (even.get(b) ^ even.get(a-2)) << endl;
			}
			else cout << 0 << endl;
		}
	}
}

signed main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;
	//cin >> t;

	while(t--)
		solve();
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 3 ms 460 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 7068 KB Output is correct
2 Correct 97 ms 7500 KB Output is correct
3 Correct 94 ms 7364 KB Output is correct
4 Correct 83 ms 7116 KB Output is correct
5 Correct 89 ms 7176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 3 ms 460 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 90 ms 7068 KB Output is correct
16 Correct 97 ms 7500 KB Output is correct
17 Correct 94 ms 7364 KB Output is correct
18 Correct 83 ms 7116 KB Output is correct
19 Correct 89 ms 7176 KB Output is correct
20 Correct 88 ms 10764 KB Output is correct
21 Correct 90 ms 10776 KB Output is correct
22 Correct 95 ms 10788 KB Output is correct
23 Correct 83 ms 10624 KB Output is correct
24 Correct 82 ms 10648 KB Output is correct