# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604715 | Tigryonochekk | Stations (IOI20_stations) | C++17 | 918 ms | 800 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 <iostream>
#include "stations.h"
#include <vector>
#define ll long long
using namespace std;
const int N = 1002;
vector<int> g[N];
vector<int> labels;
int tin[N], tout[N];
int timer = 0;
void dfs(int v, int p) {
tin[v] = timer++;
for (int to : g[v]) {
if (p == to) continue;
dfs(to, v);
}
tout[v] = timer;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
labels.clear();
for (int i = 0; i < n; i++) {
g[i].clear();
}
timer = 0;
for (int i = 0; i < n - 1; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
dfs(0, -1);
for (int i = 0; i < n; i++) {
labels.push_back(tin[i] * N + tout[i]);
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if (c.size() == 1)
return c[0];
int n = c.size();
int si = s / N, so = s % N;
int ti = t / N, to = t % N;
vector<int> ci, co;
for (int i = 0; i < n; i++) {
ci.push_back(c[i] / N);
co.push_back(c[i] % N);
}
// kam c0-n s-i parentn a, kam el che. erku depqum el ete muys gagatnerov gnal, u vochmeki erexen chlini t-n, apa c0-n a.
for (int i = 1; i < ci.size(); i++) {
if (ci[i] <= ti && co[i] >= to) {
return c[i];
}
}
return c[0];
}
/*
1
5 1000000000
4 2
3 1
0 2
0 3
5
4 0 2
2 4 4
3 4 0
0 1 3
0 3 3
1
7 1000000000
0 1
0 2
1 3
1 4
2 5
2 6
4
0 4 1
1 4 4
1 5 0
3 5 1
1
7 1000000000
0 3
1 4
2 5
3 6
4 6
5 6
4
6 0 3
3 0 0
3 6 6
3 1 6
*/
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... |