# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1163777 | ChottuF | Railway (BOI17_railway) | C++20 | 117 ms | 45316 KiB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5;
const int MAXH = 22;
vector<vector<int>> adj;
int up[MAXH][MAXN], depth[MAXN];
int tin[MAXN], tout[MAXN], timer = 0;
// DFS to compute depth, parent pointers, and tin/tout times.
void dfs(int x, int p, int d) {
depth[x] = d;
up[0][x] = p;
tin[x] = ++timer;
for(auto u : adj[x]) {
if(u == p) continue;
dfs(u, x, d+1);
}
tout[x] = timer;
}
int jmp(int x, int k) {
for (int i = 0; i < MAXH; i++) {
if(k & (1 << i))
x = up[i][x];
}
return x;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |