Submission #319635

#TimeUsernameProblemLanguageResultExecution timeMemory
319635jovan_bXOR (IZhO12_xor)C++17
0 / 100
137 ms21348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int trie[2000005]; int sled[2000005][2]; int mn[2000005]; int cnt; int x; void trieadd(int v, int ind){ int node = 0; mn[node] = min(mn[node], ind); for(int i=29; i>=0; i--){ if(v&(1<<i)){ if(!sled[node][1]) sled[node][1] = ++cnt; node = sled[node][1]; } else{ if(!sled[node][0]) sled[node][0] = ++cnt; node = sled[node][0]; } mn[node] = min(mn[node], ind); } } int query(int v){ int node = 0; int res = 1000000; for(int i=29; i>=0; i--){ if(x&(1<<i)){ int t = 1; if(v&(1<<i)) t = 0; if(!sled[node][t]) break; node = sled[node][t]; } else{ int t = 1; if(v&(1<<i)) t = 0; if(sled[node][t]){ res = min(res, mn[sled[node][t]]); } if(!sled[node][1^t]) break; node = sled[node][1^t]; } } return res; } int main(){ ios_base::sync_with_stdio(false), cin.tie(0); cout.precision(10); cout << fixed; int n; cin >> n >> x; if(x == 0){ cout << 1 << " " << n << "\n"; return 0; } for(int i=0; i<=1000000; i++) mn[i] = 1000000; x--; int xx = 0; trieadd(0, 0); int resi = 0, res = 0; for(int i=1; i<=n; i++){ int a; cin >> a; xx ^= a; int g = query(xx); if(i-g > res){ resi = g+1; res = i-g; } trieadd(xx, i); } cout << resi << " " << res << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...