# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
959035 | The_Samurai | Stations (IOI20_stations) | C++17 | 606 ms | 868 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;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<vector<int>> adj(n);
vector<int> tin(n);
vector<bool> vis(n);
for (int i = 0; i < n - 1; i++) {
adj[u[i]].emplace_back(v[i]);
adj[v[i]].emplace_back(u[i]);
}
int z = 0;
auto dfs = [&](auto &dfs, int u) -> void {
tin[u] = z++;
vis[u] = true;
for (int v: adj[u]) {
if (vis[v]) continue;
dfs(dfs, v);
}
};
dfs(dfs, 0);
// cout << '\t';
// for (int i = 0; i < n; i++) cout << tin[i] << ' ';
// cout << endl;
return tin;
}
int find_next_station(int s, int t, std::vector<int> c) {
// cout << '\t' << s << ' ' << t << endl;
// cout << '\t';
// for (int x: c) cout << x << ' ';
// cout << endl;
sort(c.begin(), c.end());
if (s == 0) {
for (int i = c.size() - 1; i >= 0; i--) if (c[i] <= t) return c[i];
}
if (t <= c[0]) return c[0];
for (int i = c.size() - 1; i >= 0; i--) {
if (c[i] <= t) return c[i];
}
}
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... |