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 depth[maxn];
int dfs_t;
void dfs(int u, int p) {
tin[u] = ++dfs_t;
for (auto v: adj[u]) {
if (v != p) {
depth[v] = depth[u] + 1;
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; i++) {
adj[i].clear();
}
for (int i = 0; i < n - 1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs_t = -1;
dfs(0, -1);
vector<int> labels(n);
for (int i = 0; i < n; i++) {
labels[i] = (depth[i] & 1 ? tout[i] : tin[i]);
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
sort(c.begin(), c.end());
if (s < c[0]) {
for (int i = 0; i < (int)c.size() - 1; i++) {
if ((i ? c[i - 1] : s) < t && t < c[i]) {
return c[i];
}
}
return c.back();
}
else {
for (int i = 1; i < (int)c.size(); i++) {
if (c[i] < t && t < (i < (int)c.size() - 1 ? c[i + 1] : s)) {
return c[i];
}
}
return c[0];
}
}
# | 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... |