Submission #1281912

#TimeUsernameProblemLanguageResultExecution timeMemory
1281912banbanThe Potion of Great Power (CEOI20_potion)C++20
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; struct SegmentTree { int N; vector<vector<pair<int, int>>> ST; SegmentTree(int n) { for (N = 1; N < n; N <<= 1){} ST = vector<vector<pair<int, int>>>(N << 1); } void rangePush(int L, int R, pair<int, int> x, int i, int l, int r) { if (r <= L || R <= l) return; if (L <= l && r <= R) { ST[i].push_back(x); return; } int m = (l + r) / 2; rangePush(L, R, x, i << 1, l, m); rangePush(L, R, x, i << 1 | 1, m, r); } void rangePush(int L, int R, pair<int, int> x) { rangePush(L, R, x, 1, 0, N); } void sortAll() { for (int i = 1; i < (N << 1); ++i) sort(ST[i].begin(), ST[i].end()); } vector<int> pointGet(int p, int v) { vector<int> ans; for (p += N; p; p >>= 1) { int i = lower_bound(ST[p].begin(), ST[p].end(), make_pair(v, 0)) - ST[p].begin(); while (i < (int)(ST[p].size()) && ST[p][i].first == v) ans.push_back(ST[p][i++].second); } return ans; } }; int N, D, U; int H[100000]; void init(int n, int d, int h[]) { N = n; D = d; for (int i = 0; i < n; i++) H[i] = h[i]; } void curseChanges(int u, int A[], int B[]) { U = u; SegmentTree ST(U + 1); map<pair<int, int>, int> mp; for (int i = 0; i < U; ++i) { if (mp[make_pair(A[i], B[i])] > 0) { ST.rangePush(mp[make_pair(A[i], B[i])], i + 1, make_pair(A[i], B[i])); ST.rangePush(mp[make_pair(A[i], B[i])], i + 1, make_pair(B[i], A[i])); mp[make_pair(A[i], B[i])] = 0; } else mp[make_pair(A[i], B[i])] = i + 1; } for (auto e : mp) if (e.second) { ST.rangePush(e.second, U + 1, e.first); ST.rangePush(e.second, U + 1, e.first); } ST.sortAll(); } void question(int x, int y, int v) { auto X = ST.pointGet(v, x); auto Y = ST.pointGet(v, y); for (int i = 0; i < (int)(X.size()); ++i) X[i] = H[X[i]]; for (int i = 0; i < (int)(Y.size()); ++i) Y[i] = H[Y[i]]; sort(X.begin(), X.end()); sort(Y.begin(), Y.end()); int ans = (int)(1e9); for (int i = 0, j = 0; i < (int)(X.size()); ++i) { while (j < (int)(Y.size()) && X[i] > Y[j]) ++j; if (j < (int)(Y.size())) ans = min(ans, abs(X[i] - Y[j])); if (j) ans = min(ans, abs(X[i] - Y[j - 1])); } return ans; }

Compilation message (stderr)

potion.cpp: In function 'void question(int, int, int)':
potion.cpp:87:18: error: 'ST' was not declared in this scope
   87 |         auto X = ST.pointGet(v, x);
      |                  ^~
potion.cpp:109:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
  109 |         return ans;
      |                ^~~