제출 #319633

#제출 시각아이디문제언어결과실행 시간메모리
319633jovan_bXOR (IZhO12_xor)C++17
0 / 100
118 ms34020 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int trie[1000005]; int sled[1000005][2]; int mn[1000005]; 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; 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...