Submission #625206

# Submission time Handle Problem Language Result Execution time Memory
625206 2022-08-09T15:34:57 Z lovrot XORanges (eJOI19_xoranges) C++11
0 / 100
15 ms 4180 KB
#include <bits/stdc++.h> 
#include <unistd.h>

#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define pri(i, poc, n, pov) for(int i = (int) poc; i < (int) n; i += (int) pov)
#define od(i, poc, n, pov) for(int i = (int) poc; i > (int) n; i -= (int) pov)

using namespace std;

const int LOG = 20;
const int OFF = (1 << LOG);
const int N = 1e6;

struct node{ 
	int sum[2] = {0, 0};
} tour[32][N];

int n, q; 

void update(int t, int x, int val){
	x += OFF; 
	tour[t][x].sum[x % 2] = val;
	x /= 2;
	while(x){ 
		pri(i, 0, 2, 1)
			tour[t][x].sum[i] = tour[t][x * 2].sum[i] + tour[t][x * 2 + 1].sum[i];
		x /= 2;
	}
}

int query(int t, int b, int l, int r, int lo = 0, int hi = OFF, int x = 1){ 
	if(r <= lo || hi <= l) return 0;
	if(l <= lo && hi <= r) return tour[t][x].sum[b];
	int mi = (lo + hi) / 2;
	return query(t, b, l, r, lo, mi, x * 2) + query(t, b, l, r, mi, hi, x * 2 + 1);
}

int main(){ 
	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);

	cin >> n >> q;

	pri(i, 0, n, 1){
		int x;
		cin >> x;
		pri(j, 0, 32, 1){
			bool b = (x & (1 << j)) > 0; 
			update(j, i, b);
		}
	}

	pri(i, 0, q, 1){ 
		int t, x, y;
		cin >> t >> x >> y;
		if(t == 1){ 
			pri(j, 0, 32, 1){
				bool b = (y  & (1 << j)) > 0; 
				update(j, x - 1, b);
			}		
		} else { 
			int ans = 0; 
			x--;
			y--;
			int p = (y - x + 1) % 2;
			if(!p){ 
				cout << 0 << "\n";
				continue;
			}
			// pri(j, 0, 32, 1){ 
			// 	int res = query(j, x % 2, x, y + 1);
			// 	ans += (1 << j) * (res % 2);
			// }
			cout << ans << "\n";
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 4180 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 4180 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 4180 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 4128 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 4180 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -