LCA- recent common ancestor four solution

Luo Gu template title P3379

Given a multi-rooted tree, a request to specify two points directly to the nearest common ancestor.

ST table

Multiply

Tarjan

Tree chain split

Guess you like

Origin www.cnblogs.com/tldr/p/11291807.html