Submission #936102

#TimeUsernameProblemLanguageResultExecution timeMemory
936102starchanXOR (IZhO12_xor)C++17
0 / 100
1 ms348 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)^1; 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-1; 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; } int X = -1; for(int i = 0; i <= n-l; i++) { if(a[i]^a[i+l] >= x) X = i+1; } cout << X << " " << l << "\n"; return 0; }

Compilation message (stderr)

xor.cpp: In function 'int main()':
xor.cpp:91:18: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   91 |   if(a[i]^a[i+l] >= x)
#Verdict Execution timeMemoryGrader output
Fetching results...