Submission #973268

#TimeUsernameProblemLanguageResultExecution timeMemory
973268terracottaliteXORanges (eJOI19_xoranges)C++14
100 / 100
106 ms7852 KiB
#include <stdio.h> int fw[2][200005] = { { 0 } }; int n, q; int query(int r, int op) { int ans = 0; while (r > 0) { ans ^= fw[op][r]; r -= r & (-r); } return ans; } void update(int p, int v) { int op = p&1; int av = query(p, op)^query(p-1, op)^v; while (p <= n) { fw[op][p] ^= av; p += p & (-p); } } int main() { scanf("%d %d", &n, &q); for (int i=1;i<=n;i++) { int x; scanf("%d", &x); update(i, x); } while (q--) { int action; scanf("%d", &action); if (action == 1) { int i, v; scanf("%d %d", &i, &v); update(i, v); } else { int l, u; scanf("%d %d", &l, &u); if ((u-l+1)%2 == 0) { puts("0"); continue; } int op = l%2; printf("%d\n", query(u, op)^query(l-1, op)); } } }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d %d", &n, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~
xoranges.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
xoranges.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%d", &action);
      |   ~~~~~^~~~~~~~~~~~~~~
xoranges.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |    scanf("%d %d", &i, &v);
      |    ~~~~~^~~~~~~~~~~~~~~~~
xoranges.cpp:45:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |    scanf("%d %d", &l, &u);
      |    ~~~~~^~~~~~~~~~~~~~~~~
#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...