Submission #761189

#TimeUsernameProblemLanguageResultExecution timeMemory
761189KN200711XORanges (eJOI19_xoranges)C++14
100 / 100
108 ms5156 KiB
# include <bits/stdc++.h> using namespace std; int seg[2][400010]; int arr[200001], gj[200001], gn[200001]; const int MXN = 1e5 + 1; void build(int lf, int rg, int nd, int ct) { if(lf == rg) { if(ct == 1) seg[ct][nd] = gj[lf]; else seg[ct][nd] = gn[lf]; } else { int mid = (lf + rg)/2; build(lf, mid, 2*nd+1, ct); build(mid+1, rg, 2*nd+2, ct); seg[ct][nd] = seg[ct][2*nd+1] ^ seg[ct][2*nd+2]; } } void upd(int lf, int rg, int pos, int nd, int val, int ct) { if(lf == rg) { seg[ct][nd] = val; } else { int mid = (lf + rg)/2; if(pos <= mid) upd(lf, mid, pos, 2*nd+1, val, ct); else upd(mid+1, rg, pos, 2*nd+2, val, ct); seg[ct][nd] = seg[ct][2*nd+1] ^ seg[ct][2*nd+2]; } } int qry(int lf, int rg, int clf, int crg, int nd, int ct) { if(clf > rg || lf > crg) return 0; if(clf <= lf && rg <= crg) return seg[ct][nd]; int mid = (lf + rg)/2; return qry(lf, mid, clf, crg, 2*nd+1, ct) ^ qry(mid+1, rg, clf, crg, 2*nd+2, ct); } int main() { int N, Q; scanf("%d %d", &N, &Q); for(int i=0;i<N;i++) { scanf("%d", &arr[i]); if(i&1) gj[i/2] = arr[i]; else gn[i/2] = arr[i]; } build(0, MXN, 0, 0); build(0, MXN, 0, 1); while(Q--) { int a, b, c; scanf("%d %d %d", &a, &b, &c); if(a == 2) { b--; c--; if((c - b)&1) printf("0\n"); else { printf("%d\n", qry(0, MXN, b/2, c/2, 0, b&1)); } } else { b--; upd(0, MXN, b/2, 0, c, b&1); } } return 0; }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf("%d %d", &N, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~~
xoranges.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d", &arr[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
xoranges.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   scanf("%d %d %d", &a, &b, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...