Submission #1129488

#TimeUsernameProblemLanguageResultExecution timeMemory
1129488hamzabcXOR (IZhO12_xor)C++20
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define mod 1000000007 #define sp << " " << #define endl << '\n' template<typename _t> _t inp(){ _t i; cin >> i; return i; } class tree{ private: struct node{ long long int data = 0; node* l = nullptr,* r = nullptr; }; node* root = nullptr; void _add(long long int l, long long int x, long long int tl, long long int tr, node* &rt){ if (l > tr || tl > l) return; if (!rt){ rt = new node; } rt->data = x; if (l == tl && tr == l){ return; } long long int mid = (tl + tr) >> 1; _add(l, x, tl, mid, rt->l); _add(l, x, mid + 1, tr, rt->r); } long long int _count(long long int l, long long int tl, long long int tr, node* &rt){ if (!rt) return 0; if (l >= tr) return rt->data; if (tl > l) return -1; long long int mid = (tl + tr) >> 1; return max(_count(l, tl, mid, rt->l), _count(l, mid + 1, tr, rt->r)); } public: void add(long long int l, long long int x){ _add(l, x, 0, 1e9, root); } long long int count(long long int l){ return _count(l, 0, 1e9, root); } }; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); tree segtre; long long int N = inp<long long int>(), X = inp<long long int>(); vector<long long int> xrs(N); for (int i = 0; i < N; i++){ if (i) xrs[i] = xrs[i - 1]; xrs[i] ^= inp<long long int>(); segtre.add(xrs[i], i); } long long int ri = 0, rk = 0, tmp; for (int i = 0; i < N; i++){ tmp = segtre.count(X ^ xrs[i]); if (tmp - i + 1 > rk){ rk = tmp - i + 1; ri = i; } } cout << ri + 1 sp rk; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...