Submission #571499

#TimeUsernameProblemLanguageResultExecution timeMemory
571499vbeeXOR (IZhO12_xor)C++14
0 / 100
2 ms4180 KiB
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define ii pair<int,int> #define vii vector<ii> #define vi vector<int> #define fi first #define se second #define TASK "c" #define ll long long #define pll pair<ll, ll> #define vll vector<ll> #define vpll vector<pll> #define pb push_back #define MASK(i) (1 << (i)) #define BIT(x, i) ((x >> (i)) & 1) using namespace std; const int oo = 1e9 + 7; const ll loo = (ll)1e18 + 7; const int N = 250007; int n, x, a[N], prexor[N]; struct segtree{ vector<int> t; void setup(){ t.resize(4 * N + 7); } void update(int v, int lt, int rt, int pos, int value){ if (lt == rt) return (void)(t[v] = value); int middle = (rt + lt) / 2; if (pos <= middle) update(v * 2, lt, middle, pos, value); else update(v * 2 + 1, middle + 1, rt, pos, value); t[v] = min(t[v * 2], t[v * 2 + 1]); } int query(int v, int lt, int rt, int y){ if (t[v] > y) return -1; if (lt == rt) return lt; int middle = (rt + lt) / 2; if (t[v * 2] <= y) return query(v * 2, lt, middle, y); else return query(v * 2 + 1, middle + 1, rt, y); } }seg; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // freopen(TASK".inp", "r", stdin); // freopen(TASK".out", "w", stdout); cin >> n >> x; for (int i = 1; i <= n; i++){ cin >> a[i]; prexor[i] = prexor[i - 1] ^ a[i]; } seg.setup(); for (int i = 1; i <= n; i++) seg.update(1, 1, n, i, prexor[i]); int id = 0, k = 0; for (int i = 1; i <= n; i++){ int cur = x ^ prexor[i]; int res = seg.query(1, 1, n, cur); if (res != -1){ res++; int len = i - res + 1; if (len > 0){ if (len > k){ k = len; id = res; } else if (len == k){ id = min(id, res); } } } } cout << id << " " << k; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...