#include "stations.h"
#include <cstdio>
#include <cassert>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
std::vector<int> g[1001];
int tin[1001], tout[1001], tim = -1, bs = 1000;
void dfs(int x, int pr) {
tin[x] = ++tim;
for (auto y : g[x]) if (y != pr) dfs(y, x);
tout[x] = tim;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for (int i = 0; i < n; i++) g[i].clear(), tin[i] = tout[i] = 0;
tim = -1;
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);
std::vector<int> ans(n);
for (int i = 0; i < n; i++) {
ans[i] = tin[i] * bs + tout[i];
//std::cout << ans[i] << " " << tin[i] << " " << tout[i] << "\n";
}
return ans;
}
int find_next_station(int s, int t, std::vector<int> c) {
int tins = s / bs, touts = s % bs, tint = t / bs, toutt = t % bs;
int st = 0;
if (tint <= tins && touts <= toutt) st = 2;
if (tins <= tint && toutt <= touts) st = 1;
for (auto i : c) {
int tinc = i / bs, toutc = i % bs;
if (st == 1 && tinc <= tint && toutt <= toutc) return i;
if (st == 1 && tinc <= tins && touts <= toutc) return i;
if (st == 0 && tinc <= tins && touts <= toutc) return i;
if (st == 2 && tinc <= tins && touts <= toutc) return i;
}
assert(0);
return -52;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
386 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
575 ms |
684 KB |
Output is correct |
2 |
Incorrect |
457 ms |
684 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
371 ms |
688 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |