{"raw_statement":[{"iden":"statement","content":"See PDF statement in attachment.\n\n"},{"iden":"examples","content":"Input2 12 0 00 2 0Output0.500000000.50000000Input2 22 0 010 10 10Output1.000000001.00000000Input2 22 0 00 1 1Output0.989854301.01014568"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of nodes.  \nLet $ P = (p_1, p_2, \\dots, p_n) $ be the parent array, where $ p_i \\in \\{0, 1, \\dots, i-1\\} $, and $ p_i = 0 $ indicates node $ i $ is a root.  \nLet $ T = (V, E) $ be the rooted forest with $ V = \\{1, 2, \\dots, n\\} $ and $ E = \\{ (p_i, i) \\mid p_i \\neq 0 \\} $.  \n\n**Constraints**  \n1. $ 1 \\leq n \\leq 10^5 $  \n2. $ 0 \\leq p_i < i $ for all $ i \\in \\{1, \\dots, n\\} $  \n\n**Objective**  \nFind a permutation $ A = (a_1, a_2, \\dots, a_n) $ of $ \\{1, 2, \\dots, n\\} $ such that, when the method from the previous problem is applied to $ A $, the resulting forest (in terms of parent-child structure) is isomorphic to $ T $ under node relabeling.  \n\nThe method (from previous problem):  \n- Nodes are processed in order $ 1 $ to $ n $.  \n- Each node $ i $ is attached as a child to the *rightmost* previously processed node with value *greater than* $ a_i $.  \n- If no such node exists, it becomes a root.  \n\n**Goal**: Construct $ A $ such that the *tree structure* induced by this rule is isomorphic to $ T $.","simple_statement":"Given a forest of n nodes with parent relationships, find any array of n distinct integers from 1 to n such that applying the digit-root-based tree construction method (from the previous problem) produces a forest with the same structure — up to node relabeling.","has_page_source":false}