Submission #467134

#TimeUsernameProblemLanguageResultExecution timeMemory
467134radaiosm7XORanges (eJOI19_xoranges)C++98
100 / 100
134 ms3816 KiB
#include <bits/stdc++.h> using namespace std; int n, q, i, a, b, quer; int c[200005]; int fen[2][200005]; void Update() { for (int indx=a; indx <= n; indx += (indx&(-indx))) fen[a&1][indx] ^= b^c[a]; c[a] = b; } int Query(int indx) { int x = 0; for (; indx > 0; indx -= (indx&(-indx))) x ^= fen[a&1][indx]; return x; } int main() { scanf("%d%d", &n, &q); for (i=1; i <= n; ++i) scanf("%d", &c[i]); for (i=1; i <= n; ++i) { a = i; b = c[i]; c[i] = 0; Update(); } fen[0][0] = 0; fen[1][0] = 0; while (q--) { scanf("%d%d%d", &quer, &a, &b); if (quer == 1) Update(); else if ((a&1) != (b&1)) printf("0\n"); else printf("%d\n", Query(b)^Query(a-1)); } return 0; }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d%d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:20:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   for (i=1; i <= n; ++i) scanf("%d", &c[i]);
      |                          ~~~~~^~~~~~~~~~~~~
xoranges.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d%d%d", &quer, &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...