# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
956419 | Desh03 | Stations (IOI20_stations) | C++17 | 614 ms | 1548 KiB |
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;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<vector<int>> g(n);
for (int i = 0; i < n - 1; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
vector<int> in(n), en(n), d(n);
int t = 0;
auto dfs = [&](const auto &self, int u) -> void {
in[u] = t++;
for (int v : g[u]) {
g[v].erase(find(g[v].begin(), g[v].end(), u));
d[v] = d[u] + 1;
self(self, v);
}
en[u] = t++;
};
dfs(dfs, 0);
vector<int> id(n);
for (int i = 0; i < n; i++) {
if (d[i] % 2 == 0) {
id[i] = in[i];
} else {
id[i] = en[i];
}
}
return id;
}
int find_next_station(int s, int t, vector<int> c) {
if (c[0] > s) {
int in = s + 1;
for (int i = 0; i < c.size() - 1; i++) {
if (in <= t && t <= c[i]) {
return c[i];
}
in = c[i] + 1;
}
return c.back();
} else {
int en = s;
for (int i = c.size() - 1; i > 0; i--) {
if (c[i] <= t && t <= en) {
return c[i];
}
en = c[i] - 1;
}
return c[0];
}
}
Compilation message (stderr)
# | 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... |