{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\n 小陆有一个 $n$ 个节点的树, 树根为 $1$. \u003cbr\u003e\u003cbr\u003e每个节点 $i$ 有一个权值 $a_i$, $\\textbf{没有任意两个节点有相同的权值}$. \u003cbr\u003e\u003cbr\u003e定义每个节点有一个分数 $b_i$ ,节点的分数定义为它子树权值$a_i$的MEX. \u003cbr\u003e\u003cbr\u003e不幸的是,你需要自己定义 $a_i$ .请自己决定 $a_i$,让总分 $\\sum_{i\u003d1}^{n}b_i$最大.\u003cbr\u003e\u003cbr\u003e$\\textbf{MEX}$ 意味着一个集合中不属于该集合的最小非负整数,例如$\\textbf{MEX}${0,1,2,4,5}\u003d3.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"一共有 $T \\left( 1 \\leq T \\leq 10 \\right)$组数据.\u003cbr\u003e\u003cbr\u003e对于每组数据:\u003cbr\u003e\u003cbr\u003e第一行 $n \\left( 1 \\le n \\le 5 \\cdot 10^5 \\right)$, 代表点的数量.\u003cbr\u003e\u003cbr\u003e接下来 $n-1$ 行, 每行两个整数 $u, v \\left(1 \\le u, v \\le n \\right)$, 代表一条树上边 $\\left( u, v \\right)$ .\u003cbr\u003e\u003cbr\u003e保证是树."}},{"title":"Output","value":{"format":"HTML","content":"对于每组数据:\u003cbr\u003e输出一行最大总分 $\\sum_{i\u003d1}^{n}b_i$."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e3\n5\n1 2\n3 2\n1 5\n4 1\n3\n1 2\n2 3\n1\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e8\n6\n1\n\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}