#include "stations.h"
#include "stub.cpp"
#include <bits/stdc++.h>
using namespace std;
vector<int> edges[1005];
int a[1005];
vector<bool> used;
int timer=0;
void dfs(int u, int d){
if(d==0)a[u] = timer,timer++;
used[u] = true;
for(auto v:edges[u]){
if(used[v])continue;
dfs(v,d^1);
}if(d==1)a[u] = timer,timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0;i<n;i++)edges[i].clear();
for(int i=0;i<n-1;i++){
edges[u[i]].push_back(v[i]);
edges[v[i]].push_back(u[i]);
}
timer=0;
used.assign(n,0);
dfs(0,0);
vector<int> ans(n);
for(int i=0;i<n;i++)ans[i] = a[i];
return ans;
}
/*
1
5 10
0 1
1 2
2 3
3 4
3
1 3 121
1 4 121
0 1 122
*/
int find_next_station(int s, int t, vector<int> c) {
// cout << s << ": " << t << '\n';
if(c[c.size()-1] < s){
int ans = c[0];
for(auto x : c){
if(min(s, x) <= t && t <= max(s, x))ans = x;
}return ans;
}else {
for(auto x : c)if(x>=t)return x;
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
55 | }
| ^
/tmp/cc9NYRUX.o: In function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cclmWa26.o:stations.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status