Submission #1070830

#TimeUsernameProblemLanguageResultExecution timeMemory
1070830matthewXORanges (eJOI19_xoranges)C++17
38 / 100
96 ms8784 KiB
#include <stdio.h> const int MAXN = 200'000; int v[MAXN + 1]; // poate fi optimizat la un singur N de memorie int aib_par[MAXN + 1]; int aib_impar[MAXN + 1]; void pointUpdate(int *aib, int pos, int delta, int n) { while(pos <= n) { aib[pos] ^= delta; pos += pos & -pos; } } int prefixQuery(int *aib, int pos) { int res = 0; while(pos > 0) { res ^= aib[pos]; pos &= pos - 1; } return res; } static inline int rangeQuery(int *aib, int l, int r) { return prefixQuery(aib, r) ^ prefixQuery(aib, l - 1); } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif int n, q, i, l, r, type, pos, val; scanf("%d%d", &n, &q); for(i = 1; i <= n; i++) { scanf("%d", &v[i]); pointUpdate((i & 1) ? aib_impar : aib_par, i, v[i], n); } for(i = 0; i < q; i++) { scanf("%d", &type); if(type == 2) { scanf("%d%d", &l, &r); if((r - l) & 1) { printf("0\n"); } else { printf("%d\n", rangeQuery((l & 1) ? aib_impar : aib_par, l, r)); } } else { scanf("%d%d", &pos, &val); pointUpdate((pos & 1) ? aib_impar : aib_par, pos, v[pos] ^ val, n); } } return 0; }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   scanf("%d%d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     scanf("%d", &v[i]);
      |     ~~~~~^~~~~~~~~~~~~
xoranges.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     scanf("%d", &type);
      |     ~~~~~^~~~~~~~~~~~~
xoranges.cpp:48:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |       scanf("%d%d", &l, &r);
      |       ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:56:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |       scanf("%d%d", &pos, &val);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~
#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...