# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705750 | PenguinsAreCute | Stations (IOI20_stations) | C++17 | 893 ms | 792 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;
#define MAXN 1005
vector<int> a[MAXN];
int pre[MAXN], post[MAXN];
int c;
void dfs(int x, int p) {
pre[x] = c++;
for(auto i: a[x]) if(i != p) dfs(i, x);
post[x] = c - 1;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
c = 0;
for(int i = 0; i < MAXN; i++) a[i].clear();
std::vector<int> labels(n);
for(int i = 0; i < n - 1; i++) {
a[u[i]].push_back(v[i]);
a[v[i]].push_back(u[i]);
}
dfs(0, -1);
for (int i = 0; i < n; i++) {
labels[i] = pre[i] * 1000 + post[i];
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s / 1000 > t / 1000 || t / 1000 > s % 1000) {
for(auto v: c) if(v / 1000 <= s / 1000 && s / 1000 <= v % 1000) return v;
}
for(auto v: c) if(v / 1000 <= t / 1000 && t / 1000 <= v % 1000 && !(v / 1000 <= s / 1000 && s / 1000 <= v % 1000)) return v;
}
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... |