#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, 0);
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 = 1;
if (tins <= tint && toutt <= touts) st = 2;
for (auto i : c) {
int tinc = i / bs, toutc = i % bs;
if (st == 0 && tinc <= tins && touts <= toutc) return i;
if (st == 1 && tinc <= tins && touts <= toutc) return i;
if (st == 2 && tinc <= tint && toutt <= toutc) return i;
}
assert(0);
return c.back();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
338 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
632 ms |
684 KB |
Output is correct |
2 |
Incorrect |
429 ms |
684 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
389 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |