Submission #1163779

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11637792025-03-08 13:03:11ChottuFRailway (BOI17_railway)C++20
100 / 100
79 ms28360 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int MAXH = 18; // since n <= 1e5, log2(n) < 18
int n, m, k;
vector<vector<int>> adj;
int depth[MAXN], parentArr[MAXN];
int up[MAXH][MAXN];
int tin[MAXN], tout[MAXN], timer = 0;
// DFS to compute tin/tout, depth and immediate parent.
void dfs(int u, int p, int d) {
depth[u] = d;
parentArr[u] = p;
tin[u] = ++timer;
up[0][u] = p;
for (int v : adj[u]) {
if (v == p) continue;
dfs(v, u, d+1);
}
tout[u] = timer;
}
// Standard binary lifting LCA.
int lca(int a, int b) {
if(depth[a] < depth[b])
swap(a, b);
int d = depth[a] - depth[b];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...