# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
329787 | chenwz | 기지국 (IOI20_stations) | C++14 | 997 ms | 1092 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> IVec;
void rec(int u, int fa, bool dfs_in, int &clock, const vector<IVec>& G, IVec& L) {
if (dfs_in) L[u] = clock++;
for (int i : G[u])
if (i != fa) rec(i, u, !dfs_in, clock, G, L);
if (!dfs_in) L[u] = clock++;
}
IVec label(int n, int k, IVec u, IVec v) {
IVec L(n);
vector<IVec> G(n, IVec());
for (size_t i = 0; i < u.size(); i++)
G[u[i]].push_back(v[i]), G[v[i]].push_back(u[i]);
int clock = 0;
rec(0, -1, true, clock, G, L);
return L;
}
int find_next_station(int s, int t, IVec c) {
if (c[0] > s) { // Case 1: s is in InClock. All the neighbors' label > s.
if (t < s || t > c.back()) return c.back(); // t not in this subtree, go to parent.
return *lower_bound(c.begin(), c.end(), t); // t is in this subtree, Pick the smallest ch >= t
}
if (t < c[0]) // Case 2: node s is in the post_order level.
return c[0]; // t not in subtree
# | 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... |