# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
593038 | Morisz10 | Stations (IOI20_stations) | C++14 | 5 ms | 804 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>
#include <cassert>
#include <map>
#include <cstdio>
using namespace std;
const int maxn = 1000;
vector<int> g[maxn];
int l;
vector<int> L, max_L, r_label;
int dfs(int x, int p) {
max_L[x] = L[x] = l++;
//cout << x << ' ' << l << '\n';
r_label[L[x]] = x;
for (int i : g[x]) {
if (i != p)max_L[x] = dfs(i, x);
}
return max_L[x];
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
L.assign(n, 0);
for (int i = 0; i < n; i++)g[i] = {};
max_L.assign(n, 0);
r_label.assign(n, 0);
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 L;
}
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_L[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... |