Submission #1281986

#TimeUsernameProblemLanguageResultExecution timeMemory
1281986SSKMFXORanges (eJOI19_xoranges)C++20
100 / 100
55 ms4556 KiB
#include <bits/stdc++.h> using namespace std; int sir[200001] , suma[2][200001]; int main () { ios :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int lungime , numar_operatii; cin >> lungime >> numar_operatii; for (int indice = 1 ; indice <= lungime ; indice++) { cin >> sir[indice]; suma[indice & 1][indice] ^= sir[indice]; if (indice + (indice & -indice) <= lungime) { suma[0][indice + (indice & -indice)] ^= suma[0][indice]; suma[1][indice + (indice & -indice)] ^= suma[1][indice]; } } while (numar_operatii--) { int8_t tip; cin >> tip; if (tip == '1') { int indice , valoare; cin >> indice >> valoare; valoare ^= sir[indice]; for (int __indice = indice ; __indice <= lungime ; __indice += (__indice & -__indice)) { suma[indice & 1][__indice] ^= valoare; } sir[indice] ^= valoare; } else { int stanga , dreapta; cin >> stanga >> dreapta; if ((dreapta - stanga + 1) % 2 == 0) { cout << "0\n"; continue; } stanga--; int __suma = 0; const int __indice = (dreapta & 1); while (stanga != dreapta) { if (stanga < dreapta) { __suma ^= suma[__indice][dreapta]; dreapta ^= (dreapta & -dreapta); } else { __suma ^= suma[__indice][stanga]; stanga ^= (stanga & -stanga); } } cout << __suma << '\n'; } } return 0; }
#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...