Square Root of LCA Convolution
You are given a rooted tree with $N$ vertices (numbered $1$ through $N$) and a prime number $P$. Vertex $1$ is the root of the tree and for each $v$ ($2 \le v \le N$), the parent of vertex $v$ is $p_v$ ($p_v \lt v$). A vertex $s$ is an ancestor of another vertex $f$ if $s$ lies on the path between $1$ and $f$ (in particular, $f$ is its own ancestor). For two vertices $u$ and $v$, let's define $
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start