# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
468364 | kessido | Stations (IOI20_stations) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fori(i,n) for(int i = 0; i < int(n); ++i)
vi label(int n, int k, const vi& u, const vi& v) {
vvi e(n);
fori(i,n-1){
e[u[i]].push_back(v[i]);
e[v[i]].push_back(u[i]);
}
int cur_label = 0;
vi res(n, -1);
auto dfs = [&](auto& self, int i, int parent) -> void {
res[i] = cur_label++;
for(int j : e[i]) {
if(j==parent) continue;
self(self, j, i);
}
};
dfs(dfs, 0, -1);
return res;
}
int find_next_station(int s, int t, vi c) {
sort(all(c));
if(t < s) return c[0]; // parent;
int i = 1;
while(i < c.size() && c[i] >= t) i++;
return c[i-1];
}