제출 #38915

#제출 시각아이디문제언어결과실행 시간메모리
38915TalantXOR (IZhO12_xor)C++14
0 / 100
0 ms4360 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define OK puts("OK"); #define pb push_back #define mk make_pair using namespace std; typedef long long ll; const int inf = (int)1e9 + 7; const int N = (int)1e5 + 7; int n,x; int a[N],p[N]; int t[N * 4]; int id,k = -1; void build (int v = 1,int tl = 1,int tr = n) { if (tl == tr) t[v] = p[tl]; else { int tm = (tl + tr) >> 1; build (v + v,tl,tm); build (v + v + 1,tm + 1,tr); t[v] = max(t[v + v],t[v + v + 1]); } } int get (int l,int r,int v = 1,int tl = 1,int tr = n) { if (tl > r || tr < l) return -inf; if (l <= tl && tr <= r) return t[v]; int tm = (tl + tr) >> 1; return max(get(l,r,v + v,tl,tm),get(l,r,v + v + 1,tm + 1,tr)); } int main () { scanf ("%d%d", &n,&x); for (int i = 1; i <= n; i ++) { scanf ("%d", &a[i]); p[i] = (p[i - 1] ^ a[i]); } build (); for (int i = 1; i <= n; i ++){ int l = i,r = n; int cur = (p[i - 1] ^ x); while (r - l > 1) { int m = (r + l) >> 1; if (get(m,n) >= cur) l = m; else r = m; } if (get(r,n) >= cur) l = r; int o = 0; if (get(l,n) < cur) o = 0; else o = l - i + 1; if (k < o) id = i,k = o; } cout << id << " " << k << endl; }

컴파일 시 표준 에러 (stderr) 메시지

xor.cpp: In function 'int main()':
xor.cpp:44:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d%d", &n,&x);
                              ^
xor.cpp:47:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf ("%d", &a[i]);
                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...