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>
using namespace std;
int ti; vector<int> ans, adj[1005];
void dfs(int i, int dep, int p){
if (dep % 2 == 0) ans[i] = ti++;
for (int to : adj[i]) if (to != p) dfs(to, dep + 1, i);
if (dep % 2 == 1) ans[i] = ti++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
ans.resize(n);
for (int i = 0; i < n; i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, 0, -1);
return ans;
}
int find_next_station(int s, int t, vector<int> c){
if (s > c[0]){ //tout layer
if (t < c[0] or t > s) return c[0];
return *prev(upper_bound(c.begin(), c.end(), t));
}
else{ //tin layer
if (t < s or t > c.back()) return c.back();
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... |