# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
311948 | Eric_hoo | Stations (IOI20_stations) | C++14 | 1041 ms | 1160 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 "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> id; int TOT;
vector <int> from[1010];
void dfs(int x, int last, int dep) {
if (dep & 1) {
id[x] = TOT++;
for (int i = 0; i < from[x].size(); i++) {
int v = from[x][i];
if (v == last) continue;
dfs(v, x, dep + 1);
}
} else {
for (int i = 0; i < from[x].size(); i++) {
int v = from[x][i];
if (v == last) continue;
dfs(v, x, dep + 1);
}
id[x] = TOT++;
}
}
vector <int> label(int n, int k, vector <int> X, vector <int> Y) {
for (int i = 0; i < n; i++) {
from[i].clear();
}
for (int i = 0; i < n - 1; i++) {
from[X[i]].push_back(Y[i]);
from[Y[i]].push_back(X[i]);
}
id.resize(n), TOT = 0, dfs(0, 0, 1);
return id;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (s < c[0]) {
int lst = s;
for (int i = 0; i + 1 < c.size(); i++) {
if (t > lst && t <= c[i]) return c[i];
}
return c.back();
}
int lst = s;
for (int i = (int)c.size() - 1; i >= 1; i--) {
if (t < lst && t >= c[i]) 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... |