Submission #223310

#TimeUsernameProblemLanguageResultExecution timeMemory
223310dantoh000Klasika (COCI20_klasika)C++14
0 / 110
587 ms3448 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, LOG_A = 30; int k; int basis[LOG_A]; int num[N]; int sz; int ct = 0; void insertVector(int mask) { for (int i = 0; i < LOG_A; i++) { if ((mask & 1 << i) == 0) continue; if (!basis[i]) { basis[i] = mask; ++sz; return; } mask ^= basis[i]; } } int maxxor(int cur){ for (int i = LOG_A; i >= 0; i--){ if ((cur & 1<<i) == 0){ if (basis[i]){ cur ^= basis[i]; } } } return cur; } int main() { int q; cin >> q; while (q--) { string Q; int a,b; cin >> Q >> a >> b; if (Q == "Add"){ num[++ct] = num[a]^b; insertVector(num[ct]); } else if (Q == "Query"){ printf("%d\n",maxxor(num[a])); } } 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...