Utkarsh and Tree Labeling
CodeChefOpen on judge ↗
Utkarsh recently found an integer M and a rooted tree having N nodes. All the the nodes are numbered from 1 to N. The tree is rooted at 1. Now Utkarsh wants to assign each node v a special value F[v] using the following procedure. - if v is a Leaf then F[v] = 0 - if v is not a Leaf then: Consider all the unique values of x such that there exits a vertex u with F[u] = x and v is an ancestor of
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