제출 #467599

#제출 시각아이디문제언어결과실행 시간메모리
467599ignusXORanges (eJOI19_xoranges)C++14
0 / 100
639 ms9292 KiB
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int N, Q; cin >> N >> Q; int ts = 2; while(ts/2<N)ts*=2; ts/=2; vector<int> a1(ts); vector<int> a(ts); for(int i = 0; i < N; i++){ if(i%2) cin >> a1[i/2+ts/2]; else cin >> a[i/2+ts/2]; } for(int i = ts/2-1; i > 0; i--) a[i]=a[i*2]^a[i*2+1]; for(int i = ts/2-1; i > 0; i--) a1[i]=a1[i*2]^a1[i*2+1]; for(int i = 0; i < Q; i++){ int optype; cin >> optype; if(optype == 1){ int j, t; cin >> j >> t; j--; j/=2; j+=ts/2; if(j%2){ a1[j]=t; j/=2; while(j!=0){ a1[j]=a1[j*2]^a1[j*2+1]; j/=2; } }else{ a[j]=t; j/=2; while(j!=0){ a[j]=a[j*2]^a[j*2+1]; j/=2; } } }else{ int l, r; cin >> l >> r; if((l-r)%2==1) { cout << 0; continue; } l--; r--; l/=2; r/=2; l+=ts/2; r+=ts/2; if(!(l%2)){ if(l==r) cout <<a[l]; int fin = a[l]^a[r]; while(l/2!=r/2){ if(!(l%2)) fin^=a[l+1]; if(r%2) fin^=a[r-1]; l/=2; r/=2; } cout << fin << '\n'; }else{ if(l==r) cout <<a1[l]; int fin = a1[l]^a1[r]; while(l/2!=r/2){ if(!(l%2)) fin^=a1[l+1]; if(r%2) fin^=a1[r-1]; l/=2; r/=2; } cout << fin << '\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...