제출 #936353

#제출 시각아이디문제언어결과실행 시간메모리
936353starchanXOR (IZhO12_xor)C++17
0 / 100
2039 ms58036 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define in pair<int, int> #define f first #define s second #define pb push_back #define pob pop_back #define INF (int)1e17 #define MX (int)3e5+5 #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL) const int LOGM = 32; struct trie { vector<int> C[2]; int chad = 0; void init() { C[0].pb(-1); C[1].pb(-1); chad++; return; } void add(int x) { int curr = 0; for(int i = LOGM-1; i >= 0; i--) { int jatin = (x>>i)&1ll; if(C[jatin][curr] == -1) { C[jatin][curr] = chad++; C[0].pb(-1); C[1].pb(-1); } curr = C[jatin][curr]; } return; } int anataa(int x) { int ans = 0; int curr = 0; for(int i = LOGM-1; i >= 0; i--) { int jatin = ((x>>i)&1ll); if(C[jatin^1][curr] != -1) { curr = C[jatin^1][curr]; ans+=(1ll<<i); } else curr = C[jatin][curr]; } return ans; } }; signed main() { fast(); int n, x; cin >> n >> x; vector<int> a(n+1, 0); for(int i = 1; i <= n; i++) { cin >> a[i]; a[i]^=a[i-1]; } int l = 1; int r = n; while(l < r) { int val = 0; int m = (l+r)/2; trie work; work.init(); work.add(a[0]); for(int i = m; i <= n; i++) { val = max(val, work.anataa(a[i])); work.add(a[i-m+1]); } if(val >= x) l = m+1; else r = m; } l--; //smallest R such that there is no i such that a[i]^a[i+R] >= x int X = -1; for(int i = 0; i <= n-l; i++) { if((a[i]^a[i+l]) >= x) { X = i+1; break; } } cout << X << " " << l << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...