제출 #1085505

#제출 시각아이디문제언어결과실행 시간메모리
1085505SunbaeXOR (IZhO12_xor)C++17
0 / 100
1 ms348 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); if(!x){ printf("1 %d", n); return 0;} 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); }

컴파일 시 표준 에러 (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:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", qs+i);
      |   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...