Submission #81827

#TimeUsernameProblemLanguageResultExecution timeMemory
81827mra2322001XOR (IZhO12_xor)C++14
0 / 100
2045 ms25776 KiB
#include <bits/stdc++.h> #define f0(i, n) for(int i(0); i < (n); i++) #define f1(i, n) for(int i(1); i <= n; i++) #define bit(x, y) (((x) >> (y))&(1ll)) using namespace std; typedef long long ll; const int N = 250002; int n, a[N], f[N], xo; map <int, int> g; void init(int b){ g.clear(); f0(i, n + 1){ int x = f[i] >> b; g[x] = i; } } int main(){ ios_base::sync_with_stdio(0); scanf("%d%d", &n, &xo); f1(i, n) scanf("%d", &a[i]), f[i] = f[i - 1]^a[i], g[f[i]] = i; int res = 0, ans = 0; f0(i, n + 1){ int cur = xo ^ f[i]; int x = g[cur] - i; if(x > res) res = x, ans = i + 1; } for(int b = 29; b >= 0; b--){ if(bit(xo, b)) continue; int now = (xo >> b); now ++; init(b); f0(i, n + 1){ int x = f[i] >> b; int cur = now ^ x; int t = g[cur] - i; if(t > res) res = t, ans = i + 1; else if(t==res){ if(i + 1 < ans) ans = i + 1; } } } printf("%d %d", ans, res); }

Compilation message (stderr)

xor.cpp: In function 'int main()':
xor.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &xo);
     ~~~~~^~~~~~~~~~~~~~~~~
xor.cpp:25:54: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     f1(i, n) scanf("%d", &a[i]), f[i] = f[i - 1]^a[i], g[f[i]] = i;
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...