Submission #653281

#TimeUsernameProblemLanguageResultExecution timeMemory
653281mychecksedadStations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back


vector<int> label(int n, int k, vector<int> u, vector<int> v){
	int timer = 0, tin[n], tout[n];
	vector<vector<int>> g(n);
	for(int i = 0; i < n-1; ++i) g[u[i]].pb(v[i]), g[v[i]].pb(u[i]);
	function<void(int, int, int)> dfs = [&](int v, int p, int d){
		if(d) tin[v] = timer++;
		for(int u: g[v]){
			if(u != p) dfs(u, v, d^1);
		}
		if(!d) tout[v] = timer++;
	};
	dfs(0, 0, 1);
	vector<int> l;
	for(int i = 0; i < n; ++i) l.pb(dep[i] % 2 == 1 ? tin[i] : tout[i]);

	return l;
}
int find_next_station(int s, int t, vector<int> c){
	if (s < c[0]) {
    if (s < t && t <= c[0]) {
      return c[0];
    }
    for (int i = 1; i < m - 1; i++) {
      if (c[i - 1] < t && t <= c[i]) {
        return c[i];
      }
    }
    return c[m - 1];
  } else {
    if (c[m - 1] <= t && t < s) {
      return c[m - 1];
    }
    for (int i = 1; i < m - 1; i++) {
      if (c[i] <= t && t < c[i + 1]) {
        return c[i];
      }
    }
    return c[0];
  }
}

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:19:34: error: 'dep' was not declared in this scope
   19 |  for(int i = 0; i < n; ++i) l.pb(dep[i] % 2 == 1 ? tin[i] : tout[i]);
      |                                  ^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:28:25: error: 'm' was not declared in this scope
   28 |     for (int i = 1; i < m - 1; i++) {
      |                         ^
stations.cpp:33:14: error: 'm' was not declared in this scope
   33 |     return c[m - 1];
      |              ^
stations.cpp:35:11: error: 'm' was not declared in this scope
   35 |     if (c[m - 1] <= t && t < s) {
      |           ^
stations.cpp:38:25: error: 'm' was not declared in this scope
   38 |     for (int i = 1; i < m - 1; i++) {
      |                         ^