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 = 1e3 + 20;
vector<int> adj[maxn];
int tin[maxn];
int tout[maxn];
int dfs_t = -1;
void dfs(int u, int p) {
tin[u] = ++dfs_t;
for (auto v: adj[u]) {
if (v != p) {
dfs(v, u);
}
}
tout[u] = dfs_t;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for (int i = 0; i < n - 1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, -1);
vector<int> labels(n);
for (int i = 0; i < n; i++) {
labels[i] = tin[i] * 1000 + tout[i];
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
int tin_s = s / 1000;
int tout_s = s % 1000;
int tin_t = t / 1000;
int tout_t = t % 1000;
int par = -1;
for (auto u: c) {
int tin_u = u / 1000;
int tout_u = u % 1000;
if (tin_u <= tin_s && tout_s <= tout_u) {
par = u;
}
else if (tin_u <= tin_t && tout_t <= tout_u) {
return u;
}
}
return par;
}
# | 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... |