제출 #537969

#제출 시각아이디문제언어결과실행 시간메모리
537969GioChkhaidzeXOR (IZhO12_xor)C++14
0 / 100
1 ms464 KiB
#include <bits/stdc++.h> using namespace std; const int N = 250005; int n, x, vl, ind, len = -1, indx, sz = 1; int s[N], D[60 * N], T[60 * N][3]; inline void rec(int id) { if (len < ind - id || (len == ind - id && id + 1 < indx)) { len = ind - id, indx = id + 1; } } inline void get(int idx, int id, int sum) { if (id == -1) { assert(sum != vl); rec(D[idx]); return ; } bool t0 = ((vl >> id) & 1), t1 = (t0 ^ 1); if (T[idx][t1] && sum + (1 << id) > vl) rec(D[T[idx][t1]]); if (T[idx][t1] && sum + (1 << id) <= vl) { get(T[idx][t1], id - 1, sum + (1 << id)); } else if (T[idx][t0]) { get(T[idx][t0], id - 1, sum); } } inline void upd(int idx, int id) { D[idx] = min(D[idx], ind); if (id == -1) return ; int t = ((vl >> id) & 1); if (!T[idx][t]) { T[idx][t] = ++sz; D[sz] = 1e9; } upd(T[idx][t], id - 1); } main () { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); D[1] = 1e9; cin >> n >> x; for (int i = 1; i <= n; ++i) { int y; cin >> y; s[i] = (s[i - 1] ^ y); ind = i, vl = s[i]; if (s[i] >= x) rec(0); upd(1, 30), get(1, 30, 0); } cout << indx << " " << len << "\n"; }

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

xor.cpp:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   39 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...