#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(a) begin(a), end(a)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
vvi edges;
int c = 0;
void dfs(int at, int from, vi &v)
{
for(auto to: edges[at])
{
if(to != from)
{
dfs(to, at, v);
}
}
v[at] = c++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<int> labels;
edges.resize(n);
labels.resize(n);
for(int i = 0; i < n - 1; i++)
{
edges[u[i]].push_back(v[i]);
edges[v[i]].push_back(u[i]);
}
dfs(0, -1, labels);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(t > s)
return c.back();
return *lower_bound(all(c), t);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |