Submission #1280279

#TimeUsernameProblemLanguageResultExecution timeMemory
1280279KerimXORanges (eJOI19_xoranges)C++17
100 / 100
68 ms4568 KiB
#include "bits/stdc++.h" using namespace std; const int N = 2e5+5; int F[2][N], a[N]; void upd(int t, int x, int v){ for (;x < N; x += x&(-x)) F[t][x] ^= v; } int get(int t, int x){ int res = 0; for (;x;x-=x&(-x)) res ^= F[t][x]; return res; } int tap(int t, int l, int r){ return get(t, r) ^ get(t, l-1); } int main(){ // freopen("file.in", "r", stdin); int n, q; scanf("%d%d", &n, &q); for (int i = 1; i <= n; i++){ int x; scanf("%d", &x); a[i] = x; upd(i%2, i, x); } while (q--){ int t; scanf("%d", &t); if (t == 1){ int p, v; scanf("%d%d", &p, &v); upd(p%2, p, a[p]^v); a[p] = v; } else{ int l, r; scanf("%d%d", &l, &r); if ((r-l)%2 == 0) printf("%d\n", tap(l%2, l, r)); else puts("0"); } } }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d%d", &n, &q);
      |         ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:25:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |                 scanf("%d", &x);
      |                 ~~~~~^~~~~~~~~~
xoranges.cpp:31:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |                 scanf("%d", &t);
      |                 ~~~~~^~~~~~~~~~
xoranges.cpp:34:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |                         scanf("%d%d", &p, &v);
      |                         ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:40:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |                         scanf("%d%d", &l, &r);
      |                         ~~~~~^~~~~~~~~~~~~~~~
#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...