Submission #220350

#TimeUsernameProblemLanguageResultExecution timeMemory
220350Matteo_VerzXORanges (eJOI19_xoranges)C++11
100 / 100
149 ms8788 KiB
/* `-/oo+/- `` .oyhhhhhhyo.`od +hhhhyyoooos. h/ +hhyso++oosy- /s .yoooossyyo:``-y` ..----.` ``.-/+:.` `````..-::/. `..```.-::///` `-.....--::::/: `.......--::////: `...`....---:::://: `......``..--:::::///:` `---.......--:::::////+/` ----------::::::/::///++: ----:---:::::///////////:` .----::::::////////////:-` `----::::::::::/::::::::- `.-----:::::::::::::::- ...----:::::::::/:-` `.---::/+osss+:` ``.:://///-. */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <cmath> using namespace std; const int INF = 2e9; const int N = 2e5; int n, q; int v[5 + N]; class AIB{ private: int a[5 + N]; int lsb(int i){ return (i & (-i)); } public: void Build(int pos, int val){ for(int i = pos; i <= n; i += lsb(i)) a[i] = a[i] ^ val; } void Update(int pos, int val){ for(int i = pos; i <= n; i += lsb(i)) a[i] = a[i] ^ v[pos] ^ val; v[pos] = val; } int Query(int pos){ int s(0); for(int i = pos; i >= 1; i -= lsb(i)) s ^= a[i]; return s; } }; AIB FenwOdd, FenwEven; int main() { #ifdef CP freopen("xoranges.in", "r", stdin); freopen("xoranges.out", "w", stdout); #endif // CP scanf("%d%d", &n, &q); for(int i = 1; i <= n; i++){ scanf("%d", &v[i]); if(i & 1) FenwOdd.Build(i, v[i]); else FenwEven.Build(i, v[i]); } while(q--){ int t, x, y; scanf("%d%d%d", &t, &x, &y); if(t == 1){ if(x & 1) FenwOdd.Update(x, y); else FenwEven.Update(x, y); } else{ if((x - y + 1) & 1){ if(y & 1) printf("%d\n", FenwOdd.Query(y) ^ FenwOdd.Query(x - 2)); else printf("%d\n", FenwEven.Query(y) ^ FenwEven.Query(x - 2)); } else printf("0\n"); } } return 0; }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:82:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &v[i]);
         ~~~~~^~~~~~~~~~~~~
xoranges.cpp:89:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &t, &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...