Y Figures
You are given a tree with N nodes, numbered from 1 to N. It is rooted at node 1, and each node i is labelled with a positive integer labeli. ‘Y Figures’ of a node X are defined as the number of ordered triplets of nodes (A, B, C) satisfying: - labelA = labelB = labelC = labelX. - A is an ancestor of X. - B and C are in the subtree of X and LCA(B,C) = X. - A, B, C, X are pairwise distinct. Yo
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