{"id":1971,"date":"2022-06-22T06:25:56","date_gmt":"2022-06-21T22:25:56","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=1971"},"modified":"2022-06-22T18:52:13","modified_gmt":"2022-06-22T10:52:13","slug":"codeforces-round-800","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/","title":{"rendered":"Codeforces Round #800 (Div.1)"},"content":{"rendered":"<h2><span class=\"ez-toc-section\" id=\"%E4%BC%A0%E9%80%81%E9%97%A8\"><\/span>\u4f20\u9001\u95e8<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><a href=\"https:\/\/codeforces.com\/contest\/1693\">https:\/\/codeforces.com\/contest\/1693<\/a><\/li>\n<li><a href=\"https:\/\/www.bilibili.com\/video\/BV18Y411T71q\">https:\/\/www.bilibili.com\/video\/BV18Y411T71q<\/a><\/li>\n<li><a href=\"https:\/\/www.acfun.cn\/v\/ac35355359_3\">https:\/\/www.acfun.cn\/v\/ac35355359_3<\/a><\/li>\n<li><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/530668156\">https:\/\/zhuanlan.zhihu.com\/p\/530668156<\/a><\/li>\n<li><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/529953575\">https:\/\/zhuanlan.zhihu.com\/p\/529953575<\/a><\/li>\n<\/ul>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a1dfef7d48a1\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a1dfef7d48a1\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/#%E4%BC%A0%E9%80%81%E9%97%A8\" title=\"\u4f20\u9001\u95e8\">\u4f20\u9001\u95e8<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/#Problem_B_Fake_Plastic_Trees\" title=\"Problem B. Fake Plastic Trees\">Problem B. Fake Plastic Trees<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/#Problem_C_Keshi_in_Search_of_AmShZ\" title=\"Problem C. Keshi in Search of AmShZ\">Problem C. Keshi in Search of AmShZ<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/#Problem_D_Decinc_Dividing\" title=\"Problem D. Decinc Dividing\">Problem D. Decinc Dividing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/#Problem_E_Outermost_Maximums\" title=\"Problem E. Outermost Maximums\">Problem E. Outermost Maximums<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/#Problem_F_I_Might_Be_Wrong\" title=\"Problem F. I Might Be Wrong\">Problem F. I Might Be Wrong<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/#%E9%A2%98%E6%84%8F\" title=\"\u9898\u610f\">\u9898\u610f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-800\/#%E9%A2%98%E8%A7%A3\" title=\"\u9898\u89e3\">\u9898\u89e3<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n<p>\u8fd9\u573a\u9898\u76ee\u975e\u5e38\u4e0d\u9519\uff0c\u6709\u70b9 atc \u7684\u611f\u89c9\u4e86 &#8230;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Problem_B_Fake_Plastic_Trees\"><\/span>Problem B. Fake Plastic Trees<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u9898\u610f\uff1a\u7ed9\u5b9a\u4e00\u68f5\u6709\u6839\u6811\uff0c\u6bcf\u4e00\u4e2a\u8282\u70b9\u6709\u4e00\u4e2a\u533a\u95f4 l[i], r[i]\u3002\u6bcf\u6b21\u64cd\u4f5c\u53ef\u4ee5\u9009\u62e9\u4ece\u6839\u51fa\u53d1\u7684\u8def\u5f84\uff0c\u6cbf\u7740\u8def\u5f84\u4e0a\u7684\u6bcf\u4e2a\u70b9\u589e\u52a0\u4e00\u4e2a\u6570\uff0c\u6ee1\u8db3\u589e\u52a0\u7684\u6570\u7ec4\u6210\u7684\u5e8f\u5217\u975e\u9012\u51cf\uff0c<br \/>\n\u95ee\u81f3\u5c11\u591a\u5c11\u6b21\u64cd\u4f5c\uff0c\u80fd\u591f\u6ee1\u8db3\u6bcf\u4e2a\u8282\u70b9\u7684\u503c\u90fd\u5728\u5176\u7ed9\u5b9a\u7684\u533a\u95f4\u91cc\u3002<\/p>\n<p>\u9898\u89e3\uff1a\u6811 DP<\/p>\n<p>\u5148\u5f31\u5316\u95ee\u9898\uff0c\u5047\u8bbe l[i] = r[i]\u3002<br \/>\n\u8bbe dp[u] \u8868\u793a\u4ee5 u \u4e3a\u6839\u8282\u70b9\u7684\u5b50\u6811\u90fd\u6ee1\u8db3\u6761\u4ef6\u65f6\uff0c\u81f3\u5c11\u9700\u8981\u591a\u5c11\u6b21\u64cd\u4f5c\u3002<br \/>\n\u90a3\u4e48\u6709 dp[u] = \\sum dp[v] + (\\sum r[v] &lt; r[u])\u3002<\/p>\n<p>\u56de\u5230\u539f\u95ee\u9898\uff0c\u6211\u4eec dp \u8fc7\u7a0b\u4e2d\u8d2a\u5fc3\u7684\u8ba9\u6bcf\u4e2a\u8282\u70b9\u7684\u6807\u53f7\u5c3d\u53ef\u80fd\u5927\u5373\u53ef\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int N = int(2e5) + 9;\r\n \r\nVI adj&#x5B;N]; LL l&#x5B;N], r&#x5B;N];\r\nint n, z;\r\n \r\nvoid dfs(int u) {\r\n    LL s = 0; for (int v: adj&#x5B;u]) dfs(v), s += r&#x5B;v];\r\n    if (s &lt; l&#x5B;u]) ++z;\r\n    else checkMin(r&#x5B;u], s);\r\n}\r\n \r\nint main(){\r\n \r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n    \/\/freopen(&quot;\/Users\/minakokojima\/Documents\/GitHub\/ACM-Training\/Workspace\/out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n \r\n    Rush {\r\n        RD(n); REP_1(i, n) adj&#x5B;i].clear();\r\n        FOR_1(i, 2, n) adj&#x5B;RD()].PB(i);\r\n        REP_1(i, n) RD(l&#x5B;i],r&#x5B;i]);\r\n        z = 0; dfs(1);\r\n        cout &lt;&lt; z &lt;&lt; endl;\r\n    }\r\n}\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Problem_C_Keshi_in_Search_of_AmShZ\"><\/span>Problem C. Keshi in Search of AmShZ<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"Problem_D_Decinc_Dividing\"><\/span>Problem D. Decinc Dividing<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u79f0\u4e00\u4e2a\u6570\u7ec4\u6ee1\u8db3 DecInc\uff0c\u5982\u679c\u5b83\u53ef\u4ee5\u7531\u4e00\u4e2a\u9012\u51cf\u548c\u4e00\u4e2a\u9012\u589e\u5e8f\u5217\u6784\u6210\uff08\u53ef\u4e3a\u7a7a\uff09\u3002<br \/>\n\u73b0\u7ed9\u5b9a\u4e00\u4e2a\u6392\u5217 P\uff0c\u95ee\u5b83\u6709\u591a\u5c11\u8fde\u7eed\u5b50\u5e8f\u5217\u6ee1\u8db3 DecInc\u3002<\/p>\n<p>\u8fd9\u4e2a DP \u6211\u89c9\u5f97\u633a\u96be\u7684\u3002\u3002\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int N = int(2e5) + 9;\r\n \r\nint a&#x5B;N], f&#x5B;N], g&#x5B;N], n;\r\n\/\/ f_i, in inc, max dec\r\n\/\/ g_i, in dec, min inc\r\n \r\nint main(){\r\n \r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n    \/\/freopen(&quot;\/Users\/minakokojima\/Documents\/GitHub\/ACM-Training\/Workspace\/out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n \r\n    RD(n); REP(i, n) RD(a&#x5B;i]);\r\n    LL z = 0; int p = n;\r\n    DWN(i, n, 0) {\r\n        f&#x5B;i] = n+1; g&#x5B;i] = 0;\r\n        FOR(j, i+1, n) {\r\n            int fj = 0, gj = n+1;\r\n            if (a&#x5B;j-1] &lt; a&#x5B;j]) checkMax(fj, f&#x5B;j-1]);\r\n            if (g&#x5B;j-1] &lt; a&#x5B;j]) checkMax(fj, a&#x5B;j-1]);\r\n            if (a&#x5B;j-1] &gt; a&#x5B;j]) checkMin(gj, g&#x5B;j-1]);\r\n            if (f&#x5B;j-1] &gt; a&#x5B;j]) checkMin(gj, a&#x5B;j-1]);\r\n            if (fj == f&#x5B;j] &amp;&amp; gj == g&#x5B;j]) break;\r\n            f&#x5B;j] = fj; g&#x5B;j] = gj;\r\n            if (fj == 0 &amp;&amp; gj == n+1) {\r\n                p = j;\r\n                break;\r\n            }\r\n        }\r\n        z += p-i;\r\n    }\r\n    cout &lt;&lt; z &lt;&lt; endl;\r\n}\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Problem_E_Outermost_Maximums\"><\/span>Problem E. Outermost Maximums<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u9898\u610f\uff1a\u7ed9\u5b9a\u4e00\u4e2a\u957f\u5ea6\u4e3a n+2 \u7684\u6570\u7ec4\uff0c\u8bbe a[0] = a[n+1] = 0\u3002\u6bcf\u4e00\u6b65\u4f60\u53ef\u4ee5\uff1a<br \/>\n&#8211; \u5c06\u6700\u5de6\u8fb9\u7684\u6700\u5927\u503c\u4fee\u6539\u4e3a\u5b83\u5de6\u8fb9\u7684\u6b21\u5927\u503c\u3002<br \/>\n&#8211; \u5c06\u6700\u53f3\u8fb9\u7684\u6700\u5927\u503c\u4fee\u6539\u4e3a\u5b83\u53f3\u8fb9\u7684\u6b21\u5927\u503c\u3002<\/p>\n<p>\u95ee\u81f3\u5c11\u591a\u5c11\u6b21\u64cd\u4f5c\uff0c\u53ef\u4ee5\u8ba9\u6570\u7ec4\u5168\u90e8\u53d8\u4e3a 0\u3002<\/p>\n<p>\u4e2a\u4eba\u89c9\u5f97\u8fd9\u4e2a\u9898\u975e\u5e38\u4f18\u96c5\u3002\u3002\u3002<\/p>\n<p><a href=\"https:\/\/codeforces.com\/blog\/entry\/103952\">\u5b98\u65b9\u9898\u89e3<\/a> \u6ca1\u770b\u61c2\u3002\u3002<a href=\"https:\/\/codeforces.com\/blog\/entry\/103952?#comment-923400\">\u8bc4\u8bba\u533a\u91cc Endagorion \u7684\u9898\u89e3<\/a> \u6362\u4e86\u79cd\u8bf4\u6cd5\uff0c\u548c <a href=\"https:\/\/codeforces.com\/blog\/entry\/103952\">\u5b98\u65b9\u9898\u89e3<\/a> \u7b49\u4ef7\uff0c\u8fd8\u662f\u4e0d\u592a\u597d\u61c2\u3002\u3002\u3002<br \/>\n\u4f46\u662f\u5b98\u65b9\u9898\u89e3\u5728\u6700\u540e\u7684\u94fe\u63a5\u91cc <a href=\"https:\/\/codeforces.com\/blog\/entry\/103952?#comment-923531\">\u63a8\u8350\u4e86\u4e00\u4efd\u6765\u81ea ecnerwala \u7684\u9898\u89e3<\/a>\uff0c\u8fd9\u4e2a\u9898\u89e3\u548c\u4e0a\u9762\u7684\u505a\u6cd5\u975e\u5e38\u4e0d\u540c\uff0c\u975e\u5e38\u5bb9\u6613\u4e3d\u6d01\uff01<br \/>\n\u4e0b\u9762\u6211\u4eec\u6765\u8bb2\u4e00\u4e0b\u8fd9\u4e2a\u3002\u3002\u3002<\/p>\n<p>\u9996\u5148\u8fd9\u4e2a E \u9898\u662f\u4e00\u4e2a\u591a\u9636\u6bb5\u51b3\u7b56\u95ee\u9898\uff0c\u5bf9\u4e8e\u8fd9\u7c7b\u95ee\u9898\u901a\u5e38\u7684\u505a\u6cd5\u662f dp\uff0c\u4f46\u662f\u6211\u4eec\u5f88\u96be\u8bbe\u8ba1\u72b6\u6001\u8fdb\u884c dp\u3002\u3002\u3002<br \/>\n\u5bf9\u4e8e\u591a\u9636\u6bb5\u51b3\u7b56\u95ee\u9898\uff0c\u5f53\u7136\u8fd8\u6709\u4e00\u4e2a\u53ef\u80fd\u7684\u505a\u6cd5\u5c31\u662f\u8d2a\u5fc3\uff0c\u7136\u540e\u8fd9\u4e2a\u9898\u6709\u4e00\u4e2a\u7ed3\u8bba\uff1a\u5bf9\u4e8e\u5f53\u524d\u51b3\u7b56\u7684\u6570\uff0c\u6bcf\u6b21\u90fd\u627e\u4e24\u8fb9\u8f83\u5c0f\u7684\u6570\u8fdb\u884c\u8f6c\u79fb\u3002\uff08\u867d\u7136\u6211\u89c9\u5f97\uff0c\u8fd9\u4e2a\u7ed3\u8bba\u4e5f\u4e0d\u662f\u5f88\u663e\u7136\u3002\u3002\uff09<\/p>\n<p>\u8003\u8651\u6784\u9020\u89e3\uff0c\u6211\u4eec\u53d1\u73b0\u5149\u6709\u8fd9\u4e2a\u7ed3\u8bba\u8fd8\u662f\u4e0d\u591f\uff0c\u8003\u8651\u91cd\u590d\u6570\u5b57\u3002\u3002\u53ef\u80fd\u5728\u67d0\u4e2a\u9636\u6bb5\uff0c\u5de6\u53f3\u4e24\u8fb9\u7684\u6570\u5927\u5c0f\u4e00\u6837\uff0c\u8fd9\u6837\u6211\u4eec\u53c8\u4e0d\u77e5\u9053\u600e\u4e48\u8f6c\u79fb\u4e86\u3002\u3002\u5b98\u65b9\u9898\u89e3\u662f\u5148\u5f31\u5316\u95ee\u9898\uff0c\u53ea\u8003\u8651\u6392\u5217\u3002\u3002\u4f46\u662f\u6211\u89c9\u5f97\u8fd9\u6b65\u5f31\u5316\u6536\u6548\u751a\u5fae\u3002\u3002<br \/>\n\u9996\u5148\u4fee\u6539\u6570\u5b57\u7684\u8fc7\u7a0b\u672c\u8eab\u5c31\u4f1a\u51fa\u73b0\u91cd\u590d\u6570\u5b57\uff0c\u800c\u4e14\u6700\u540e\u8fd8\u662f\u8981\u56de\u6765\u5904\u7406\u91cd\u590d\u6570\u5b57\u7684\u95ee\u9898\u3002\u3002\u5e76\u4e0d\u662f\u5f88\u76f4\u89c2\u3002\u3002<\/p>\n<p>\u8fd9\u4efd\u9898\u89e3\u5219\u63d0\u4f9b\u4e86\u4e00\u79cd\u975e\u5e38 nice \u7684\u601d\u8def\u3002\u3002\u800c\u4e14\u91cd\u590d\u6570\u5b57\u5bf9\u8fd9\u4e2a\u505a\u6cd5\u5b8c\u5168\u4e0d\u5f71\u54cd\u3002\u3002\u3002<\/p>\n<p>\u65b9\u6cd5\u5c31\u662f\u5ef6\u8fdf\u5904\u7406\u3002\u3002\u65e2\u7136\u5f53\u524d\u9636\u6bb5\u4e0d\u597d\u505a\u5224\u65ad\uff0c\u90a3\u4e48\u4e0d\u5982\u5148\u6253\u4e2a ? \u6807\u8bb0\u3002\u3002\u3002<\/p>\n<p>\u6211\u4eec\u6309\u7167\u4ece\u5927\u5230\u5c0f\u7684\u987a\u5e8f\u5904\u7406\u6240\u6709\u7684\u6570\u5b57\uff08\u6211\u89c9\u5f97\u8fd9\u6bd4\u9898\u89e3\u4ece\u5de6\u5411\u53f3\u7684\u987a\u5e8f\u8981\u597d\u5f97\u591a\uff01\uff09\u3002<\/p>\n<p>\u90a3\u4e48\u5f53\u5904\u7406\u5230\u4e00\u4e2a\u6570\u5b57\u65f6\uff0c\u8003\u5bdf\u5f53\u524d\u8f6e\u6b21\uff0c\u8fd9\u4e9b\u76f8\u540c\u7684\u6570\u5b57\u6240\u5f62\u6210\u7684\u533a\u95f4\uff0c<\/p>\n<p>\u6240\u6709\u5728\u8fd9\u4e2a\u533a\u95f4\u5de6\u4fa7\u7684 \uff1f\u90fd\u7f6e\u4e3a &lt;\u3002\uff08\u56e0\u4e3a\u540e\u7eed\u80af\u5b9a\u6709\u66f4\u5c0f\u7684\u6570\u51fa\u73b0\u5728\u5b83\u4eec\u7684\u5de6\u4fa7\uff09<br \/>\n\u6240\u6709\u5728\u8fd9\u4e2a\u533a\u95f4\u53f3\u4fa7\u7684 \uff1f\u90fd\u7f6e\u4e3a >\u3002<br \/>\n\u91cd\u5408\u7684\u90e8\u5206\u4f9d\u7136\u662f ?\u3002\uff08\u8fd9\u4e9b\u4f4d\u7f6e\u5f53\u524d\u8f6e\u6b21\u7684\u51b3\u7b56\u4e0d\u5f71\u54cd\u7ed3\u679c\uff09<br \/>\n\u4ee5\u6837\u4f8b 2 \u90a3\u4e2a\u6392\u5217\u4e3a\u4f8b\u3002\u3002\u3002\u8fc7\u7a0b\u5c31\u662f\uff1a<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\/\/13542\r\n\/\/..?.. +1\r\n\/\/..&lt;?. +1\r\n\/\/.??&gt;. +2\r\n\/\/.&lt;&lt;?? +2\r\n\/\/???&gt;&gt; +3\r\n<\/pre>\n<p>\u6bcf\u4e2a\u4f4d\u7f6e\u88ab\u6807\u8bb0\u6210 ? \u90fd\u4f1a\u5bf9\u7b54\u6848\u5e26\u6765 +1 \u7684\u8d21\u732e\uff0c\u800c\u4e14\u8fd9\u4e9b ? \u6807\u8bb0\u6bcf\u4e2a\u8f6e\u6b21\u90fd\u6784\u6210\u4e00\u4e2a\u8fde\u7eed\u7684\u533a\u95f4\u3002\u3002\u3002\u53ea\u8981\u5f00\u4e2a\u6811\u72b6\u6570\u7ec4\u628a\u5904\u7406\u8fc7\u7684\u4f4d\u7f6e\uff0c\u6bcf\u6b21\u5355\u70b9 +1\uff0c\u5e76\u7ef4\u62a4\u5f53\u524d\u533a\u95f4\u7684\u4f4d\u7f6e\uff0c\u6bcf\u6b21\u52a0\u4e0a\u533a\u95f4\u548c\u5c31\u53ef\u4ee5\u4e86\u3002\u3002Orz\u3002\u3002<\/p>\n<p>\u4ee3\u7801\u5f88\u77ed\u3002\u3002\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Problem_F_I_Might_Be_Wrong\"><\/span>Problem F. I Might Be Wrong<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"%E9%A2%98%E6%84%8F\"><\/span>\u9898\u610f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a 01 \u5e8f\u5217\uff0c\u6bcf\u6b21\u64cd\u4f5c\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u5b50\u533a\u95f4\u8fdb\u884c\u6392\u5e8f\uff0c\u4ee3\u4ef7\u662f\u8fd9\u4e2a\u533a\u95f4 0 \u548c 1 \u6570\u91cf\u7684\u5dee\u518d + 1\u3002<br \/>\n\u95ee\u6700\u5c11\u591a\u5c11\u4ee3\u4ef7\u5b8c\u6210\u6392\u5e8f\u3002<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E9%A2%98%E8%A7%A3\"><\/span>\u9898\u89e3<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u7ed3\u8bba\uff1a\u53ea\u9700\u82e5\u5e72\u6b21\u4ee3\u4ef7\u4e3a 1 \u7684\u64cd\u4f5c\u3002<br \/>\n\u505a\u6cd5\uff1a<br \/>\n\u53ea\u8003\u8651 0 \u6bd4 1 \u6570\u91cf\u591a\u7684\u60c5\u51b5\uff0c\u7528\u4e00\u4e2a\u4e0b\u6807\u7ef4\u62a4\u5f53\u524d\u6700\u5de6\u4fa7 1 \u7684\u4f4d\u7f6e\uff0c\u5206\u60c5\u51b5\u8ba8\u8bba\uff1a<br \/>\n&#8211; \u662f\u5426\u5df2\u7ecf\u6392\u5e8f<br \/>\n&#8211; \u662f\u5426\u518d\u8fdb\u884c\u4e00\u6b21\u64cd\u4f5c\u53ef\u4ee5\u5b8c\u6210\u6392\u5e8f<br \/>\n&#8211; \u5426\u5219\u8fdb\u884c\u4e00\u6b21\u64cd\u4f5c\uff0c\u4f7f\u5f97\u4e0b\u6807\u5c3d\u53ef\u80fd\u5411\u53f3\u79fb\uff0c\u7ee7\u7eed\u8fed\u4ee3<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f20\u9001\u95e8 https:\/\/codeforces.com\/contest\/1693 https:\/\/www.bilibili.com\/video\/BV18Y411T71q https:\/\/www.acfun.cn\/v\/ac35355359_3 https:\/\/zhuanlan.zhihu.com\/p\/530668156 https:\/\/zhuanlan.zhihu.com\/p\/529953575 \u8fd9\u573a\u9898\u76ee\u975e\u5e38\u4e0d\u9519\uff0c\u6709\u70b9 atc \u7684\u611f\u89c9\u4e86 &#8230; Problem B. Fake Plastic Trees \u9898\u610f\uff1a\u7ed9\u5b9a\u4e00\u68f5\u6709\u6839\u6811\uff0c\u6bcf\u4e00\u4e2a\u8282\u70b9\u6709\u4e00\u4e2a\u533a\u95f4 l[i], r[i]\u3002\u6bcf\u6b21\u64cd\u4f5c\u53ef\u4ee5\u9009\u62e9\u4ece\u6839\u51fa\u53d1\u7684\u8def\u5f84\uff0c\u6cbf\u7740\u8def\u5f84\u4e0a\u7684\u6bcf\u4e2a\u70b9\u589e\u52a0\u4e00\u4e2a\u6570\uff0c\u6ee1\u8db3\u589e\u52a0\u7684\u6570\u7ec4\u6210\u7684\u5e8f\u5217\u975e\u9012\u51cf\uff0c \u95ee\u81f3\u5c11\u591a\u5c11\u6b21\u64cd\u4f5c\uff0c\u80fd\u591f\u6ee1\u8db3\u6bcf\u4e2a\u8282\u70b9\u7684\u503c\u90fd\u5728\u5176\u7ed9\u5b9a\u7684\u533a\u95f4\u91cc\u3002 \u9898\u89e3\uff1a\u6811 DP \u5148\u5f31\u5316\u95ee\u9898\uff0c\u5047\u8bbe l[i] = r[i]\u3002 \u8bbe dp[u] \u8868\u793a\u4ee5 u \u4e3a\u6839\u8282\u70b9\u7684\u5b50\u6811\u90fd\u6ee1\u8db3\u6761\u4ef6\u65f6\uff0c\u81f3\u5c11\u9700\u8981\u591a\u5c11\u6b21\u64cd\u4f5c\u3002 \u90a3\u4e48\u6709 dp[u] = \\sum dp[v] + (\\sum r[v] &lt; r[u])\u3002 \u56de\u5230\u539f\u95ee\u9898\uff0c\u6211\u4eec dp \u8fc7\u7a0b\u4e2d\u8d2a\u5fc3\u7684\u8ba9\u6bcf\u4e2a\u8282\u70b9\u7684\u6807\u53f7\u5c3d\u53ef\u80fd\u5927\u5373\u53ef\u3002 const int N = int(2e5) + 9; VI adj&#x5B;N]; LL l&#x5B;N], r&#x5B;N]; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-1971","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-vN","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=1971"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1971\/revisions"}],"predecessor-version":[{"id":1972,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1971\/revisions\/1972"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=1971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=1971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=1971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}