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 <bits/stdc++.h>
#include "stations.h"
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
int cnt;
vector<int> G[1001], labels;
void dfs(int at, int p, int d){
if(!d) labels[at] = cnt++;
for(auto next : G[at]){
if(next != p)
dfs(next, at, d^1);
}
if(d) labels[at] = cnt++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
cnt = 0;
for(int i = 0; i < n; i++){
G[i].clear();
}
for(int i = 0; i < n - 1; i++){
G[u[i]].pb(v[i]);
G[v[i]].pb(u[i]);
}
labels.resize(n);
dfs(0, -1, 0);
return labels;
}
int find_next_station(int s, int t, vector<int> c){
if(s < c[0]){
if(t < s || t >= c.back()) return c.back();
return *lower_bound(c.begin(), c.end(), t);
}
if(t > s || t <= c[0]) return c[0];
return *--lower_bound(c.begin(), c.end(), 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... |