# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1229011 | pumkinhead | Feast (NOI19_feast) | C++20 | 0 ms | 0 KiB |
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<vector<int>> graph(n);
for(int i=0; i<n-1; i++){
graph[u[i]].push_back(v[i]);
graph[v[i]].push_back(u[i]);
}
vector<int> labels(n);
int time = 0;
function<void(int, int)> dfs = [&](int node, int parent){
labels[node] = time++;
for(int neigh : graph[node]){
if(neigh == parent) continue;
dfs(neigh, node);
}
};
dfs(0, -1);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if(t < s) return c[0];
return *(upper_bound(c.begin(), c.end(), t)-1);
}