Ancestors
CodeChefOpen on judge ↗
Three trees T1, T2 and T3 having some nodes with values are given. C1, C2 and C3 denote the number of nodes of each tree for which A1, A2 and A3 and M1, M2 and M3 are to be found. Ai is the ID of the maximum common ancestor of Ci nodes for tree Ti and Mi is the value of the of that ancestor. Maximum common ancestor means the common ancestor having the maximum value. Now, these three nodes A1, A2
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