제출 #466095

#제출 시각아이디문제언어결과실행 시간메모리
466095uroskXORanges (eJOI19_xoranges)C++14
100 / 100
236 ms17660 KiB
// __builtin_popcount(x) broj bitova // __builtin_popcountll(x) long long #define here cerr<<"---------------------------\n" #include <bits/stdc++.h> #define ld double #define ll long long #define ull unsigned long long #define llinf 100000000000000000LL // 10^17 #define iinf 2000000000 // 2*10^9 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pii pair<int,int> #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) int(a.size()) #define all(a) a.begin(),a.end() #define rall(a) a.begin(),a.end(),greater<int>() using namespace std; void setIO(string inoutname) { freopen((inoutname+".in").c_str(),"r",stdin); freopen((inoutname+".out").c_str(),"w",stdout); } ll gcd(ll a, ll b) { if(b==0) return a; if(a==0) return b; if(a>=b) return gcd(a%b,b); return gcd(a,b%a); } #define maxn 200005 ll n; ll a[maxn]; ll b[maxn]; ll sega[4*maxn]; ll segb[4*maxn]; void inita(ll v,ll l,ll r){ if(l==r){ sega[v] = a[l]; return; } ll mid = (l+r)/2; inita(2*v,l,mid); inita(2*v+1,mid+1,r); sega[v] = sega[2*v]^sega[2*v+1]; } ll xora(ll v,ll tl,ll tr,ll l,ll r){ if(l>r) return 0; if(tl==l&&tr==r){ return sega[v]; } ll mid = (tl+tr)/2; return xora(2*v,tl,mid,l,min(mid,r))^xora(2*v+1,mid+1,tr,max(mid+1,l),r); } void upda(ll v,ll tl,ll tr,ll val,ll pos){ if(tl==tr){ a[tl] = val; sega[v] = val; return; } ll mid = (tl+tr)/2; if(pos<=mid) upda(2*v,tl,mid,val,pos); else upda(2*v+1,mid+1,tr,val,pos); sega[v] = sega[2*v]^sega[2*v+1]; } void initb(ll v,ll l,ll r){ if(l==r){ segb[v] = b[l]; return; } ll mid = (l+r)/2; initb(2*v,l,mid); initb(2*v+1,mid+1,r); segb[v] = segb[2*v]^segb[2*v+1]; } ll xorb(ll v,ll tl,ll tr,ll l,ll r){ if(l>r) return 0; if(tl==l&&tr==r){ return segb[v]; } ll mid = (tl+tr)/2; return xorb(2*v,tl,mid,l,min(mid,r))^xorb(2*v+1,mid+1,tr,max(mid+1,l),r); } void updb(ll v,ll tl,ll tr,ll val,ll pos){ if(tl==tr){ b[tl] = val; segb[v] = val; return; } ll mid = (tl+tr)/2; if(pos<=mid) updb(2*v,tl,mid,val,pos); else updb(2*v+1,mid+1,tr,val,pos); segb[v] = segb[2*v]^segb[2*v+1]; } void tc(){ ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); ll tip; cin >> tip; if(tip == 1){ ll pos,val; cin >> pos >> val; if(pos&1) upda(1,1,n,val,pos); else updb(1,1,n,val,pos); }else{ ll l,r; cin >> l >> r; if((r-l+1)%2==0) cout<<0<<endl; else{ if(l&1) cout<<xora(1,1,n,l,r)<<endl; else cout<<xorb(1,1,n,l,r)<<endl; } } } int main(){ ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); //setIO("lol"); int t; t = 1; cin >> n >> t; for(ll i = 1;i<=n;i++){ if(i&1) cin >> a[i]; else cin >> b[i]; } inita(1,1,n); initb(1,1,n); while(t--){ tc(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

xoranges.cpp: In function 'void setIO(std::string)':
xoranges.cpp:24:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  freopen((inoutname+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:25:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |      freopen((inoutname+".out").c_str(),"w",stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...