# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580918 | Jomnoi | Stations (IOI20_stations) | C++17 | 1039 ms | 832 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>
#include "stations.h"
using namespace std;
const int MAX_N = 1005;
int N, timer;
vector <int> graph[MAX_N];
int st[MAX_N], en[MAX_N];
void init(int n) {
N = n, timer = 0;
for(int i = 0; i < N; i++) {
st[i] = en[i] = 0;
graph[i].clear();
}
}
void dfs(int u, int p) {
st[u] = timer++;
for(auto v : graph[u]) {
if(v != p) {
dfs(v, u);
}
}
en[u] = timer - 1;
}
vector <int> label(int n, int k, vector <int> u, vector <int> v) {
init(n);
for(int i = 0; i < N - 1; i++) {
graph[u[i]].push_back(v[i]);
graph[v[i]].push_back(u[i]);
}
dfs(0, -1);
vector <int> labels(N);
for(int i = 0; i < N; i++) {
labels[i] = st[i] * 1000 + en[i];
}
return labels;
}
int find_next_station(int s, int t, vector <int> c) {
int stS = s / 1000, enS = s % 1000;
int stT = t / 1000, enT = t % 1000;
for(int i = 1; i < c.size(); i++) {
int stC = c[i] / 1000, enC = c[i] % 1000;
if(stC <= stT and enT <= enC) {
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... |