Submission #1085502

#TimeUsernameProblemLanguageResultExecution timeMemory
1085502SunbaeXOR (IZhO12_xor)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, inf = 1e9 + 7; int qs[N], cp[N<<1], m = 0, bit[N<<1]; int pos(int x){ return upper_bound(cp, cp+m, x) - cp;} void upd(int i, int val){ for(; i<=m; i+=i&-i) bit[i] = min(bit[i], val);} int qry(int i){ int res = inf; for(; i; i-=i&-i) res = min(res, bit[i]); return res;} signed main(){ int n, x; scanf("%d %d", &n, &x); for(int i = 0; i<n; ++i){ scanf("%d", qs+i); if(i) qs[i] ^= qs[i-1]; cp[m++] = qs[i]; cp[m++] = (x ^ qs[i]); } sort(cp, cp+m); m = unique(cp, cp+m) - cp; fill(bit, bit+m+1, inf); int mx_len = 0, mn_st = n; for(int i = 0; i<n; ++i){ int Qry = qry(pos(qs[i])); if(Qry < inf){ int len = i - Qry, st = Qry + 1; if(len > mx_len) mx_len = len, mn_st = st; else if(len == mx_len && st < mn_st) mn_st = st; } upd(pos(x ^ qs[i]), i); } ++mn_st; printf("%d %d", mn_st, mx_len); }

Compilation message (stderr)

xor.cpp: In function 'int main()':
xor.cpp:9:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  int n, x; scanf("%d %d", &n, &x);
      |            ~~~~~^~~~~~~~~~~~~~~~~
xor.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d", qs+i);
      |   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...