{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eArkady的花园里有一棵苹果树。它可以被表示为一组通过分支连接的节点,以便从任何一个节点到达任何其他节点只有一种方式。这些节点从$$$1$$$到$$$n$$$编号,节点$$$1$$$被称为根节点。\u003c/p\u003e\u003cp\u003e节点$$$v$$$的子树是一组节点$$$u$$$,使得从$$$u$$$到根节点的路径必须通过$$$v$$$。注意$$$v$$$本身也包含在$$$v$$$的子树中。\u003c/p\u003e\u003cp\u003e叶子是这样一个节点,它的子树只包含一个节点。\u003c/p\u003e\u003cp\u003e新年即将到来,所以Arkady想要装饰这棵树。他会在每个叶子节点上放一个某种颜色的灯泡,然后计算快乐节点的数量。一个快乐节点是这样一个节点$$$t$$$,使得$$$t$$$的子树中所有灯泡的颜色都不相同。\u003c/p\u003e\u003cp\u003eArkady对以下问题感兴趣:对于从$$$1$$$到$$$n$$$的每个$$$k$$$,需要至少多少种不同颜色才能使快乐节点的数量大于或等于$$$k$$$?\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数$$$n$$$($$$1 \\le n \\le 10^5$$$)— 树中节点的数量。\u003c/p\u003e\u003cp\u003e第二行包含$$$n - 1$$$个整数$$$p_2$$$、$$$p_3$$$、...、$$$p_n$$$($$$1 \\le p_i \u0026lt; i$$$),其中$$$p_i$$$表示节点$$$i$$$和$$$p_i$$$之间有一条分支。保证这组分支构成一棵树。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e输出$$$n$$$个整数。第$$$i$$$个整数应该是使快乐节点数量至少为$$$i$$$所需的最少颜色数。\u003c/p\u003e"}},{"title":"示例","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\u003e3\n1 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 1 2 \n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"","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\u003e5\n1 1 3 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 1 1 2 3 \n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e在第一个示例中,对于$$$k \u003d 1$$$和$$$k \u003d 2$$$,我们可以只使用一种颜色:节点$$$2$$$和$$$3$$$将会是快乐的。对于$$$k \u003d 3$$$,你必须使用不同颜色的灯泡才能使所有节点快乐。\u003c/p\u003e\u003cp\u003e在第二个示例中,对于$$$k \u003d 4$$$,你可以将颜色为$$$1$$$的灯泡放在节点$$$2$$$和$$$4$$$,将颜色为$$$2$$$的灯泡放在节点$$$5$$$。然后快乐的节点是索引为$$$2$$$、$$$3$$$、$$$4$$$和$$$5$$$的节点。\u003c/p\u003e"}}]}