제출 #79899

#제출 시각아이디문제언어결과실행 시간메모리
79899imeimi2000XOR (IZhO12_xor)C++17
100 / 100
292 ms92836 KiB
#include <cstdio> #include <unordered_map> using namespace std; typedef long long llong; typedef pair<int, int> pii; int n, k; int ansi, ansk; int a[250001]; struct node { int mx, l, r; node() : mx(-1), l(-1), r(-1) {} } ns[250000 * 31]; int tp = 1; const int inf = (1 << 30) - 1; void update(int &i, int s, int e, int x, int v) { if (i == -1) i = tp++; ns[i].mx = v; if (s == e) return; int m = (s + e) / 2; if (x <= m) update(ns[i].l, s, m, x, v); else update(ns[i].r, m + 1, e, x, v); } int query(int i, int s, int e, int x) { if (i == -1) return -1; if (((x ^ s) | (s ^ e)) < k) return -1; if (k <= ((x ^ s) & (s ^ e ^ inf))) return ns[i].mx; int m = (s + e) / 2; return max(query(ns[i].l, s, m, x), query(ns[i].r, m + 1, e, x)); } int rt = 0; int main() { scanf("%d%d", &n, &k); update(rt, 0, inf, 0, 0); for (int i = 1; i <= n; ++i) { scanf("%d", a + i); update(rt, 0, inf, a[i] ^= a[i - 1], i); } for (int i = 0; i <= n; ++i) { int mx = query(rt, 0, inf, a[i]); if (ansk < mx - i) ansk = mx - i, ansi = i + 1; } printf("%d %d\n", ansi, ansk); return 0; }

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

xor.cpp: In function 'int main()':
xor.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~
xor.cpp:41:14: 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...