제출 #625210

#제출 시각아이디문제언어결과실행 시간메모리
625210lovrotXORanges (eJOI19_xoranges)C++11
0 / 100
75 ms4188 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...