Submission #793470

# Submission time Handle Problem Language Result Execution time Memory
793470 2023-07-25T22:01:23 Z asdfgrace Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int n;
vector<int> a;
vector<vector<int>> lef, rig;

void Init(int N, int A[]) {
  n = N;
  a.resize(N);
  for (int i = 0; i < N; ++i) a[i] = A[i];
  lef.resize(N); rig.resize(N);
  queue<pair<int, int>> q;
  q.push({0, n - 1});
  while (!q.empty()) {
    int l = q.front().first, r = q.front().second;
    q.pop();
    int m = (l + r) / 2;
    lef[m].push_back(A[m]);
    for (int i = 1; i <= (m - l); ++i) {
      lef[m].push_back(Secret(A[m - i], lef[m].back()));
    }
    if (m + 1 < N) {
      rig[m].push_back(A[m + 1]);
      for (int i = 2; i <= (r - m); ++i) {
        rig[m].push_back(Secret(rig[m].back(), A[m + i]));
      }
    }
    if (l == r) continue;
    q.push({l, m});
    q.push({m + 1, r});
  }
}

int Query(int L, int R) {
  if (L == R) return a[L];
  int l = 0, r = n - 1;
  while (true) {
    int m = (l + r) / 2;
    if (R <= m) {
      r = m;
    } else if (L > m) {
      l = m + 1;
    } else {
      return Secret(lef[m][m - L], rig[m][R - m - 1]);
    }
  }
}

Compilation message

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:21:24: error: 'Secret' was not declared in this scope
   21 |       lef[m].push_back(Secret(A[m - i], lef[m].back()));
      |                        ^~~~~~
secret.cpp:26:26: error: 'Secret' was not declared in this scope
   26 |         rig[m].push_back(Secret(rig[m].back(), A[m + i]));
      |                          ^~~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:45:14: error: 'Secret' was not declared in this scope
   45 |       return Secret(lef[m][m - L], rig[m][R - m - 1]);
      |              ^~~~~~