# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
591638 | Morisz10 | Stations (IOI20_stations) | C++14 | 1 ms | 556 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 <vector>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn = 1000;
vector<int> g[maxn];
int l;
vector<int> labels, max_label, r_label;
int dfs(int x, int p) {
max_label[x] = labels[x] = l++;
r_label[labels[x]] = x;
for (int i : g[x]) {
if (i != p)max_label[x] = dfs(i, x);
}
return max_label[x];
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
labels.assign(n, 0);
max_label = labels;
for (int i = 0; i < u.size(); i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
l = 0;
dfs(0, -1);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
for (int i = 0; i < c.size() - 1; i++) {
if (t < c[i + 1])return c[i];
}
return t > max_label[r_label[c.back()]] ? c[0] : c.back();
}
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... |