MCPcopy Create free account
hub / github.com/anupam-kumar-krishnan/Competitive_Programming / kth

Function kth

All Algorithms/Graph Algorithm/LCA.cpp:25–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 return par[u][0];
24}
25int kth(int u, int k) {
26 assert(k >= 0);
27 for (int i = 0; i <= LG; i++) if (k & (1 << i)) u = par[u][i];
28 return u;
29}
30int dist(int u, int v) {
31 int l = lca(u, v);
32 return dep[u] + dep[v] - (dep[l] << 1);

Callers 1

goFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected