제출 #1028681

#제출 시각아이디문제언어결과실행 시간메모리
1028681VectorLiXOR (IZhO12_xor)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define long long long using namespace std; const int N = 250000; struct trie { int n; int e[N * 30 + 1][2]; int m[N]; trie() { for (int i = 0; i < N; i++) { m[i] = numeric_limits<int>::max(); } } void insert(int x, int p) { int u = 0; for (int i = 29; i >= 0; i--) { m[u] = min(m[u], p); int &v = e[u][(x >> i) & 1]; if (v == 0) { v = ++n; } u = v; } m[u] = min(m[u], p); } int query(int x, int k) { int u = 0; int h = numeric_limits<int>::max(); for (int i = 29; i >= 0; i--) { int b = (x >> i) & 1; if ((k >> i) & 1) { if (e[u][b ^ 1] == 0) { return -1; } else { u = e[u][b ^ 1]; } } else { if (e[u][b ^ 1] > 0) { h = min(h, m[e[u][b ^ 1]]); } if (e[u][b] == 0) { break; } else { u = e[u][b]; } } } return h; } } t; int main() { #ifdef LOCAL freopen("A.in", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; k = k - 1; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> s(n + 1); for (int i = 0; i < n; i++) { s[i + 1] = s[i] ^ a[i]; } t.insert(0, 0); int l = 0, st = 0; for (int i = 1; i < n + 1; i++) { int p = t.query(s[i], k); if (p < 0) { continue; } if (i - p + 1 > l) { l = i - p + 1; st = i; } if (i - p + 1 == l && i < st) { st = i; } t.insert(s[i], i); }#include <bits/stdc++.h> #define long long long using namespace std; const int N = 250000; struct trie { int n; int e[N * 30 + 1][2]; int m[N]; trie() { for (int i = 0; i < N; i++) { m[i] = numeric_limits<int>::max(); } } void insert(int x, int p) { int u = 0; for (int i = 29; i >= 0; i--) { m[u] = min(m[u], p); int &v = e[u][(x >> i) & 1]; if (v == 0) { v = ++n; } u = v; } m[u] = min(m[u], p); } int query(int x, int k) { int u = 0; int h = numeric_limits<int>::max(); for (int i = 29; i >= 0; i--) { int b = (x >> i) & 1; if ((k >> i) & 1) { if (e[u][b ^ 1] == 0) { return -1; } else { u = e[u][b ^ 1]; } } else { if (e[u][b ^ 1] > 0) { h = min(h, m[e[u][b ^ 1]]); } if (e[u][b] == 0) { break; } else { u = e[u][b]; } } } return h; } } t; int main() { #ifdef LOCAL freopen("A.in", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; k = k - 1; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> s(n + 1); for (int i = 0; i < n; i++) { s[i + 1] = s[i] ^ a[i]; } t.insert(0, 0); int l = 0, st = 0; for (int i = 1; i < n + 1; i++) { int p = t.query(s[i], k); if (p < 0) { continue; } if (i - p + 1 > l) { l = i - p + 1; st = i; } if (i - p + 1 == l && i < st) { st = i; } t.insert(s[i], i); } cout << st << " " << l << "\n"; return 0; } cout << st << " " << l << "\n"; return 0; }

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

xor.cpp:94:3: error: stray '#' in program
   94 |  }#include <bits/stdc++.h>
      |   ^
xor.cpp: In function 'int main()':
xor.cpp:94:4: error: 'include' was not declared in this scope
   94 |  }#include <bits/stdc++.h>
      |    ^~~~~~~
xor.cpp:94:13: error: 'bits' was not declared in this scope
   94 |  }#include <bits/stdc++.h>
      |             ^~~~
xor.cpp:94:18: error: 'stdc' was not declared in this scope; did you mean 'std'?
   94 |  }#include <bits/stdc++.h>
      |                  ^~~~
      |                  std
xor.cpp:97:1: error: expected primary-expression before 'using'
   97 | using namespace std;
      | ^~~~~
xor.cpp:151:12: error: a function-definition is not allowed here before '{' token
  151 | int main() {
      |            ^