Submission #321672

# Submission time Handle Problem Language Result Execution time Memory
321672 2020-11-13T03:07:27 Z Gilgamesh Stations (IOI20_stations) C++17
Compilation error
0 ms 0 KB
//#include "stations.h"
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned ll;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
#define PI 3.14159265

const int mxN = 1'001;

vector<int> adj[mxN];
int timer;

void dfs(int v, int p, vector<int>& labels){
	labels[timer++] = v;
	for(int i : adj[v]) {
		if(i == p) continue;
		dfs(i, v, labels);
	}
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);
	for(int i = 0; i < n - 1; ++i){
		adj[u[i]].eb(adj[v[i]]);
		adj[v[i]].eb(adj[u[i]]);
	}
	timer = 0;
	dfs(0, -1, labels);
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	sort(all(c));
	if(t < s) {
		return c[0];
	} else {
		int ans = 0;
		for(int i : c){
			if(t < i) break;
			ans = i;
		}
		return ans;
	}
}

//int main(){}

Compilation message

stations.cpp:5:13: error: 'pair' does not name a type
    5 | using pii = pair<int, int>;
      |             ^~~~
stations.cpp:6:13: error: 'pair' does not name a type
    6 | using pll = pair<ll, ll>;
      |             ^~~~
stations.cpp:19:1: error: 'vector' does not name a type
   19 | vector<int> adj[mxN];
      | ^~~~~~
stations.cpp:22:24: error: 'vector' has not been declared
   22 | void dfs(int v, int p, vector<int>& labels){
      |                        ^~~~~~
stations.cpp:22:30: error: expected ',' or '...' before '<' token
   22 | void dfs(int v, int p, vector<int>& labels){
      |                              ^
stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:23:2: error: 'labels' was not declared in this scope
   23 |  labels[timer++] = v;
      |  ^~~~~~
stations.cpp:24:14: error: 'adj' was not declared in this scope
   24 |  for(int i : adj[v]) {
      |              ^~~
stations.cpp: At global scope:
stations.cpp:30:1: error: 'vector' does not name a type
   30 | vector<int> label(int n, int k, vector<int> u, vector<int> v) {
      | ^~~~~~
stations.cpp:41:37: error: 'vector' has not been declared
   41 | int find_next_station(int s, int t, vector<int> c) {
      |                                     ^~~~~~
stations.cpp:41:43: error: expected ',' or '...' before '<' token
   41 | int find_next_station(int s, int t, vector<int> c) {
      |                                           ^
stations.cpp: In function 'int find_next_station(int, int, int)':
stations.cpp:42:11: error: 'c' was not declared in this scope
   42 |  sort(all(c));
      |           ^
stations.cpp:12:17: note: in definition of macro 'all'
   12 | #define all(x) (x).begin(),(x).end()
      |                 ^
stations.cpp:42:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   42 |  sort(all(c));
      |  ^~~~
      |  short