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 <vector>
#define ll int
#define ff first
#define ss second
#define ln "\n"
#define pll pair<ll, ll>
using namespace std;
vector<vector<ll>> A;
void dfs(ll u, ll p, vector<ll> &labels, ll &timer){
labels[u]=timer++;
for (auto v:A[u]){
if (v==p) continue;
dfs(v, u, labels, timer);
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
A.clear();
A.resize(n);
for (ll i=0; i<n-1; i++){
A[u[i]].push_back(v[i]);
A[v[i]].push_back(u[i]);
}
vector<int> labels(n);
ll time=0;
dfs(0, 0, labels, time);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
ll n = (int)c.size();
ll ret=0;
if (s>t){
for (ll i=n-1; i>=0; i--){
if (c[i]>=t) ret=c[i];
else break;
}
}else{
for (ll i=0; i<n; i++){
if (c[i]<=t) ret=c[i];
else break;
}
}
return ret;
}
# | 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... |