Submission #307575

# Submission time Handle Problem Language Result Execution time Memory
307575 2020-09-28T16:30:22 Z Mounir XORanges (eJOI19_xoranges) C++14
55 / 100
122 ms 6112 KB
#include <bits/stdc++.h>
//#define int long long
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define all(v) v.begin(), v.end()
using namespace std;

const int N = (1 << 17);
int tXor[2][N * 2];

int getXor(int ind, int gauche, int droite){
	if (droite < gauche) return 0;
	if (gauche%2 == 1) return tXor[ind][gauche]^getXor(ind, gauche + 1, droite);
	if (droite%2 == 0) return tXor[ind][droite]^getXor(ind, gauche, droite - 1);
	return getXor(ind, gauche/2, droite/2);
}

void actualiser(int ind, int noeud, int val){
	tXor[ind][noeud] = val; noeud /= 2;
	for (; noeud > 0; noeud /= 2) tXor[ind][noeud] = tXor[ind][noeud * 2]^tXor[ind][noeud * 2 + 1];
}

signed main(){
	int nVals, nReqs; cin >> nVals >> nReqs;
	for (int iVal = 0; iVal < nVals; ++iVal){
		int val; cin >> val;
		actualiser(iVal%2, N + iVal, val);
	}
	
	while (nReqs--){
		int typeReq; cin >> typeReq;
		if (typeReq == 1){
			int noeud, val; cin >> noeud >> val;
			actualiser(1 - noeud%2, N + noeud - 1, val);
		}
		else {
			int gauche, droite; cin >> gauche >> droite;
			if ((droite - gauche)%2 == 1) cout << 0 << endl;
			else cout << getXor(1 - gauche%2, N + gauche - 1, N + droite - 1) << endl;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 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 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 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 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 18 ms 640 KB Output is correct
12 Correct 19 ms 640 KB Output is correct
13 Correct 24 ms 640 KB Output is correct
14 Correct 22 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 122 ms 6112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 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 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 18 ms 640 KB Output is correct
12 Correct 19 ms 640 KB Output is correct
13 Correct 24 ms 640 KB Output is correct
14 Correct 22 ms 640 KB Output is correct
15 Runtime error 122 ms 6112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Halted 0 ms 0 KB -