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 = 1e5 + 10;
int t;
vector<int> labels, adj[MAXN];
void dfs(int v, int p, bool b) {
if (!b) labels[v] = t++;
for (int u : adj[v])
if (u != p)
dfs(u, v, !b);
if (b) labels[v] = t++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
labels.resize(n);
for (int i = 0; i < n - 1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, 0, false);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
sort(c.begin(), c.end());
bool f = s < c[0];
int n = c.size();
if (f) {
if (s == 0) {
n++;
c.push_back(MAXN);
}
if (t < s || (n == 1 || t > c[n - 2])) return c[n - 1];
return *lower_bound(c.begin(), c.end(), t);
} else {
if (t > s || (n == 1 || t < c[1])) return c[0];
return *prev(upper_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... |