{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003edd \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background-color: #f5f5f5;\n border: 1px solid #ccc;\n border-radius: 4px;\n}\u003c/style\u003e","sections":[{"title":"Description","value":{"format":"HTML","content":"\u003cdiv\u003e给定一棵n个节点的有根树,编号依次为1到n,其中1号点为根节点。每个点有一个权值v_i。\u003c/div\u003e\r\n\u003cdiv\u003e你需要将这棵树转化成一个大根堆。确切地说,你需要选择尽可能多的节点,满足大根堆的性质:对于任意两个点i,j,如果i在树上是j的祖先,那么v_i\u0026gt;v_j。\u003c/div\u003e\r\n\u003cdiv\u003e请计算可选的最多的点数,注意这些点不必形成这棵树的一个连通子树。\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv\u003e第一行包含一个正整数n(1\u0026lt;\u003dn\u0026lt;\u003d200000),表示节点的个数。\u003c/div\u003e\r\n\u003cdiv\u003e接下来n行,每行两个整数v_i,p_i(0\u0026lt;\u003dv_i\u0026lt;\u003d10^9,1\u0026lt;\u003dp_i\u0026lt;i,p_1\u003d0),表示每个节点的权值与父亲。\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv\u003e输出一行一个正整数,即最多的点数。\u003c/div\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\"vjudge_sample\"\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\u003e6\r\n3 0\r\n1 1\r\n2 1\r\n3 1\r\n4 1\r\n5 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003ch3\u003eSource\u003c/h3\u003e本OJ付费获得"}}]}