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 <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
vector<int> adj[MAXN], lbls;
int ind;
void dfs(int x, int par, bool typ){
if (typ) lbls[x] = ++ind;
for (int nxt : adj[x]){
if (nxt == par) continue;
dfs(nxt, x, !typ);
}
if (!typ) lbls[x] = ++ind;
}
vector<int> label(int nodes, int maxlbl, vector<int> u, vector<int> v) {
for (int i = 0; i < nodes; i++) adj[i].clear();
for (int i = 0; i < nodes - 1; i++){
int a = u[i], b = v[i];
adj[a].push_back(b);
adj[b].push_back(a);
}
lbls = vector<int>(nodes, -1);
ind = -1;
dfs(0, -1, 0);
return lbls;
}
int find_next_station(int s, int t, vector<int> c) {
if (s < c[0]){
if (t < s) return c.back();
else return *lower_bound(c.begin(), c.end(), t);
}
else{
if (t > s) return c[0];
else return *(upper_bound(c.begin(), c.end(), t) - 1);
}
}
# | 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... |