# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
815929 | math_rabbit_1028 | Stations (IOI20_stations) | C++14 | 617 ms | 672 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> adj[1010];
int ch[1010], ord[2020], lt[1010], rt[1010], dep[1010];
int r = -1;
void DFS(int v) {
ord[++r] = v;
lt[v] = r;
for (int i = 0; i < adj[v].size(); i++) {
int next = adj[v][i];
if (ch[next]) continue;
ch[next] = 1;
dep[next] = dep[v] + 1;
DFS(next);
ord[++r] = v;
}
rt[v] = r;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for (int i = 0; i < n - 1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
for (int i = 0; i < n; i++) ch[i] = 0;
ch[0] = 1; dep[0] = 0; r = -1;
DFS(0);
vector<int> lab(n);
for (int i = 0; i < n; i++) {
if (dep[i] % 2 == 0) lab[i] = lt[i];
else lab[i] = rt[i];
}
//for (int i = 0; i < n; i++) cout << lab[i] << " ";
//cout << "\n";
return lab;
}
int find_next_station(int s, int t, vector<int> c) {
if (s < c[0]) {
for (int i = 0; i < c.size(); i++) {
int l = ((i == 0) ? s : c[i - 1]), r = c[i];
if (l < t && t <= r) return c[i];
}
return c[c.size() - 1];
}
if (s > c[c.size() - 1]) {
for (int i = c.size() - 1; i >= 0; i--) {
int l = c[i], r = ((i == c.size() - 1) ? s : c[i + 1]);
if (l <= t && t < r) 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... |