{"problem":{"name":"Ranges on Tree","description":{"content":"You are given a rooted tree with $N$ vertices. The root is Vertex $1$.   For each $i = 1, 2, \\ldots, N-1$, the $i$\\-th edge connects Vertex $u_i$ and Vertex $v_i$. For each $i = 1, 2, \\ldots, N$, let ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc240_e"},"statements":[{"statement_type":"Markdown","content":"You are given a rooted tree with $N$ vertices. The root is Vertex $1$.  \nFor each $i = 1, 2, \\ldots, N-1$, the $i$\\-th edge connects Vertex $u_i$ and Vertex $v_i$.\nFor each $i = 1, 2, \\ldots, N$, let $S_i$ denote the set of all vertices in the subtree rooted at Vertex $i$. (Each vertex is in the subtree rooted at itself, that is, $i \\in S_i$.)\nAdditionally, for integers $l$ and $r$, let $[l, r]$ denote the set of all integers between $l$ and $r$, that is, $[l, r] = \\lbrace l, l+1, l+2, \\ldots, r \\rbrace$.\nConsider a sequence of $N$ pairs of integers $\\big((L_1, R_1), (L_2, R_2), \\ldots, (L_N, R_N)\\big)$ that satisfies the conditions below.\n\n*   $1 \\leq L_i \\leq R_i$ for every integer $i$ such that $1 \\leq i \\leq N$.\n*   The following holds for every pair of integers $(i, j)$ such that $1 \\leq i, j \\leq N$.\n    *   $[L_i, R_i] \\subseteq [L_j, R_j]$ if $S_i \\subseteq S_j$\n    *   $[L_i, R_i] \\cap [L_j, R_j] = \\emptyset$ if $S_i \\cap S_j = \\emptyset$\n\nIt can be shown that there is at least one sequence $\\big((L_1, R_1), (L_2, R_2), \\ldots, (L_N, R_N)\\big)$. Among those sequences, print one that minimizes $\\max \\lbrace L_1, L_2, \\ldots, L_N, R_1, R_2, \\ldots, R_N \\rbrace$, the maximum integer used. (If there are multiple such sequences, you may print any of them.)\n\n## Constraints\n\n*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq u_i, v_i \\leq N$\n*   All values in input are integers.\n*   The given graph is a tree.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$u_1$ $v_1$\n$u_2$ $v_2$\n$\\vdots$\n$u_{N-1}$ $v_{N-1}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc240_e","tags":[],"sample_group":[["3\n2 1\n3 1","1 2\n2 2\n1 1\n\n$(L_1, R_1) = (1, 2), (L_2, R_2) = (2, 2), (L_3, R_3) = (1, 1)$ satisfies the conditions.  \nIndeed, we have $[L_2, R_2] \\subseteq [L_1, R_1], [L_3, R_3] \\subseteq [L_1, R_1], [L_2, R_2] \\cap [L_3, R_3] = \\emptyset$.  \nAdditionally, $\\max \\lbrace L_1, L_2, L_3, R_1, R_2, R_3 \\rbrace = 2$ is the minimum possible value."],["5\n3 4\n5 4\n1 2\n1 4","1 3\n3 3\n2 2\n1 2\n1 1"],["5\n4 5\n3 2\n5 2\n3 1","1 1\n1 1\n1 1\n1 1\n1 1"]],"created_at":"2026-03-03 11:01:13"}}