제출 #1097569

#제출 시각아이디문제언어결과실행 시간메모리
1097569vjudge1XORanges (eJOI19_xoranges)C++17
0 / 100
60 ms9552 KiB
#include<bits/stdc++.h> using namespace std; #define forsn(i,s,n) for(int i=int(s);i<int(n);i++) #define forn(i,n) forsn(i,0,n) #define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--) #define dforn(i,n) dforsn(i,0,n) #define sz(x) int(x.size()) #define all(x) begin(x),end(x) #define pb push_back typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int,int> ii; struct FTree{ int n; vi ft,v; FTree(int _n):n(_n+4),ft(n,0),v(n,0){} void upd(int i, int x){ for(++i;i<n;i+=i&-i) ft[i]^=x; } void set(int i, int x){ upd(i,v[i]^x); v[i]=x; } int get(int i){ int s=0; for(++i;i;i-=i&-i) s^=ft[i]; return s; } int query(int l, int r){ return get(r)-get(l-1); } }; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,q; cin>>n>>q; FTree even(n),odd(n); forn(i,n){ int x; cin>>x; if(i&1) odd.set(i,x); else even.set(i,x); } forn(_,q){ int t; cin>>t; if(t==1){ int p,x; cin>>p>>x; p--; if(p&1) odd.set(p,x); else even.set(p,x); }else{ int l,r; cin>>l>>r; l--,r--; if((r-l)&1) cout<<"0\n"; else{ if(l&1) cout<<odd.query(l,r)<<'\n'; else cout<<even.query(l,r)<<'\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...