# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
934104 | EJIC_B_KEDAX | Stations (IOI20_stations) | C++17 | 538 ms | 1124 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 ll = long long;
using namespace std;
vector<vector<int>> g;
vector<int> res;
void dfs(int s, int p = -1, int d = 0) {
if (~d & 1) {
res.push_back(s);
}
for (int i : g[s]) {
if (i != p) {
dfs(i, s, d + 1);
}
}
if (d & 1) {
res.push_back(s);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
g.resize(n);
for (int i = 0; i < n; i++) {
g[i].clear();
}
res.clear();
for (int i = 0; i < n - 1; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
dfs(0);
return res;
}
int find_next_station(int s, int t, vector<int> c) {
if (c[0] > s) {
if (t < s) {
return c.back();
}
for (int i = 0; i < c.size(); i++) {
if (c[i] >= t) {
return c[i];
}
}
return c.back();
} else {
if (t > s) {
return c[0];
}
for (int i = c.size() - 1; i >= 0; i--) {
if (c[i] <= t) {
return c[i];
}
}
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... |