Submission #1254965

#TimeUsernameProblemLanguageResultExecution timeMemory
1254965flashmtObstacles for a Llama (IOI25_obstacles)C++20
Compilation error
0 ms0 KiB
#include "obstacles.h"
#include <bits/stdc++.h>
#ifdef LOCAL
#include "Debug.h"
#else
#define debug(...) 42
#endif
using namespace std;

template<typename T>
struct SparseTable
{
  int n;
  vector<vector<T>> mat;

  SparseTable(const vector<T>& a)
  {
    n = int(a.size());
    int maxLog = 32 - __builtin_clz(n);
    mat.resize(maxLog);
    mat[0] = a;
    for (int j = 1; j < maxLog; j++)
    {
      mat[j].resize(n - (1 << j) + 1);
      for (int i = 0; i <= n - (1 << j); i++)
        mat[j][i] = max(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
    }
  }

  T get(int from, int to)
  {
    assert(0 <= from && from <= to && to <= n - 1);
    int lg = 31 - __builtin_clz(to - from + 1);
    return max(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
  }
};

int n, m;
vector<int> t, h;
int isSub2;
SparseTable<int> *st;

void initialize(vector<int> _t, vector<int> _h) {
  t = _t; h = _h;
  n = size(t); m = size(h);
  isSub2 = 1;
  for (int i = 0; i + 1 < n; i++)
    if (t[i] > t[i + 1])
      isSub2 = 0;

  st = new SparseTable(h);
}

bool can_reach(int l, int r, int from, int to) {
  return st->get(from, to) < t[n - 1];

Compilation message (stderr)

obstacles.cpp: In function 'bool can_reach(int, int, int, int)':
obstacles.cpp:55:39: error: expected '}' at end of input
   55 |   return st->get(from, to) < t[n - 1];
      |                                       ^
obstacles.cpp:54:48: note: to match this '{'
   54 | bool can_reach(int l, int r, int from, int to) {
      |                                                ^