Submission #372997

# Submission time Handle Problem Language Result Execution time Memory
372997 2021-03-03T00:30:27 Z Kanon Stations (IOI20_stations) C++14
Compilation error
0 ms 0 KB
#include <station.h>
#include <bits/stdc++.h>

using namespace std;

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
  vector<vector<int>> g(n);
  for(int i = 0; i < n - 1; i++) {
    int a = u[i], b = v[i];
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> ret(n, -1);
  vector<int> sub(n);
  vector<int> par(n);
  function<void(int, int)> dfs = [&](int v, int p) {
    par[v] = p;
    sub[v] = 1;
    for(int i : g[v]) {
      if(i == p) continue;
      dfs(i, v);
      sub[v] += sub[i];
    }
  };
  dfs(0, -1);
  function<void(int, int, int, bool)> solve = [&](int v, int L, int R, bool head) {
    ret[v] = head ? L : R;
    int st = L + head;
    for(int i : g[v]) {
      if(i == par[v]) continue;
      solve(i, st, st + sub[i] - 1, !head);
      st += sub[i];
    }
  };
  solve(0, 0, n - 1, true);
  return ret;
}

int find_next_station(int s, int t, vector<int> c) {
  if(c.size() == 1) return c[0];
  int n = c.size();
  int par = -1;
  for(int i : c) if(par == -1 || abs(s - i) > abs(s - par)) par = i;
  for(int i = 0; i < n; i++) if(c[i] == par) {
    c.erase(c.begin() + i);
    break;
  }
  c.push_back(s);
  sort(c.begin(), c.end());
  int beg = c[0], fin = c[n - 1];
  if(t < beg || t > fin) return par;
  if(beg == s) {
    return *lower_bound(c.begin(), c.end(), t);
  } else {
    return *prev(upper_bound(c.begin(), c.end(), t));
  }
}

Compilation message

stations.cpp:1:10: fatal error: station.h: No such file or directory
    1 | #include <station.h>
      |          ^~~~~~~~~~~
compilation terminated.