{"id":564,"date":"2023-02-28T20:47:28","date_gmt":"2023-02-28T12:47:28","guid":{"rendered":"https:\/\/lolife.top\/?p=564"},"modified":"2023-03-04T20:40:38","modified_gmt":"2023-03-04T12:40:38","slug":"acwing-3729-%e6%94%b9%e5%8f%98%e6%95%b0%e7%bb%84%e5%85%83%e7%b4%a0","status":"publish","type":"post","link":"https:\/\/lolife.top\/?p=564","title":{"rendered":"AcWing 3729. \u6539\u53d8\u6570\u7ec4\u5143\u7d20"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u9898\u76ee<\/h3>\n\n\n\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u7a7a\u6570\u7ec4&nbsp;V&nbsp;\u548c\u4e00\u4e2a\u6574\u6570\u6570\u7ec4&nbsp;a1,a2,\u2026,an\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\u8981\u5bf9\u6570\u7ec4&nbsp;V&nbsp;\u8fdb\u884c&nbsp;n&nbsp;\u6b21\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u7b2c&nbsp;i&nbsp;\u6b21\u64cd\u4f5c\u7684\u5177\u4f53\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4ece\u6570\u7ec4&nbsp;V\u5c3e\u90e8\u63d2\u5165\u6574\u6570&nbsp;0<\/li>\n\n\n\n<li>\u5c06\u4f4d\u4e8e\u6570\u7ec4&nbsp;V\u672b\u5c3e\u7684&nbsp;ai\u4e2a\u5143\u7d20\u90fd\u53d8\u4e3a&nbsp;1\uff08\u5df2\u7ecf\u662f&nbsp;1&nbsp;\u7684\u4e0d\u4e88\u7406\u4f1a\uff09\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ai&nbsp;\u53ef\u80fd\u4e3a&nbsp;0\uff0c\u5373\u4e0d\u505a\u4efb\u4f55\u6539\u53d8\u3002<\/li>\n\n\n\n<li>ai&nbsp;\u53ef\u80fd\u5927\u4e8e\u76ee\u524d\u6570\u7ec4&nbsp;V&nbsp;\u6240\u5305\u542b\u7684\u5143\u7d20\u4e2a\u6570\uff0c\u6b64\u65f6\u89c6\u4e3a\u5c06\u6570\u7ec4\u5185\u6240\u6709\u5143\u7d20\u53d8\u4e3a&nbsp;1\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8bf7\u4f60\u8f93\u51fa\u6240\u6709\u64cd\u4f5c\u5b8c\u6210\u540e\u7684\u6570\u7ec4&nbsp;V\u3002<\/p>\n\n\n\n<p><strong>\u8f93\u5165\u683c\u5f0f<\/strong><\/p>\n\n\n\n<p>\u7b2c\u4e00\u884c\u5305\u542b\u6574\u6570&nbsp;T\uff0c\u8868\u793a\u5171\u6709&nbsp;T&nbsp;\u7ec4\u6d4b\u8bd5\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u6bcf\u7ec4\u6570\u636e\u7b2c\u4e00\u884c\u5305\u542b\u6574\u6570&nbsp;n\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e8c\u884c\u5305\u542b&nbsp;n&nbsp;\u4e2a\u6574\u6570&nbsp;a1,a2,\u2026,an\u3002<\/p>\n\n\n\n<p><strong>\u8f93\u51fa\u683c\u5f0f<\/strong><\/p>\n\n\n\n<p>\u6bcf\u7ec4\u6570\u636e\u8f93\u51fa\u4e00\u884c\u7ed3\u679c\uff0c\u8868\u793a\u6240\u6709\u64cd\u4f5c\u5b8c\u6210\u540e\u7684\u6570\u7ec4&nbsp;V\uff0c\u6570\u7ec4\u5185\u5143\u7d20\u4e4b\u95f4\u7528\u7a7a\u683c\u9694\u5f00\u3002<\/p>\n\n\n\n<p><strong>\u6570\u636e\u8303\u56f4<\/strong><\/p>\n\n\n\n<p>1\u2264T\u226420000,<br>1\u2264n\u22642\u00d710e5,<br>0\u2264ai\u2264n,<br>\u4fdd\u8bc1\u4e00\u4e2a\u6d4b\u8bd5\u70b9\u5185\u6240\u6709&nbsp;n\u7684\u548c\u4e0d\u8d85\u8fc7&nbsp;2\u00d710e5\u3002<\/p>\n\n\n\n<p><strong>\u8f93\u5165\u6837\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 2\n3\n0 0 0<\/code><\/pre>\n\n\n\n<p><strong>\u8f93\u51fa\u6837\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1 1 0 1 1 1\n0 1 1 1 1 1 0 0 1 1\n0 0 0<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u601d\u8def\uff1a<\/strong><\/h3>\n\n\n\n<p>\u6bcf\u6b21\u64cd\u4f5c\u90fd\u4f1a\u63d2\u51650\uff0c\u6240\u4ee5\u6570\u7ec4\u6700\u540e\u7684\u957f\u5ea6\u662f2*n\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u4ece\u540e\u5f80\u524d\u626b\u63cf\uff0c\u53ef\u4ee5\u4f7fi\u4f4d\u7f6e\u5f00\u59cb\u5f80\u524da[i]\u957f\u5ea6\u5185\u53d8\u62101<\/p>\n\n\n\n<p>\u6bcf\u6b21\u66f4\u65b0\u8fb9\u754c<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4ee3\u7801\uff1a<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream&gt;\n#include&lt;cmath&gt;\n#include&lt;cstring&gt;\nusing namespace std;\nint v&#91;200005],ans&#91;200005];\nint t,n;\nint main()\n{\n\t\n\tcin &gt;&gt; t;\n\twhile (t--)\n\t{\n\t\tmemset(ans, 0, sizeof(ans));\/\/\u521d\u59cb\u5316ans\u6570\u7ec4\n\t\tcin &gt;&gt; n;\n\t\tfor (int i = 1; i &lt;= n; i++)\n\t\t{\n\t\t\tcin &gt;&gt; v&#91;i];\n\t\t}\n\t\tint l = v&#91;n];\n\t\tfor (int i = n; i &gt;= 1; i--)\n\t\t{\n\t\t\tl = max(l, v&#91;i]);\/\/\u66f4\u65b0\u8fb9\u754c\n\t\t\tif (l &gt; 0)\n\t\t\t{\n\t\t\t\tl--;\n\t\t\t\tans&#91;i] = 1;\n\t\t\t}\n\t\t}\n\t\tfor (int i = 1; i &lt;= n; i++)\n\t\t{\n\t\t\tcout &lt;&lt; ans&#91;i] &lt;&lt; \" \";\n\t\t}\n\t\tcout &lt;&lt; \"\\n\";\n\t}\n\t\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee \u7ed9\u5b9a\u4e00\u4e2a\u7a7a\u6570\u7ec4&nbsp;V&nbsp;\u548c\u4e00\u4e2a\u6574\u6570\u6570\u7ec4&nbsp;a1,a2,\u2026,an\u3002 \u73b0\u5728\u8981\u5bf9\u6570\u7ec4&#038; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[19],"class_list":["post-564","post","type-post","status-publish","format-standard","hentry","category-20","tag-19"],"_links":{"self":[{"href":"https:\/\/lolife.top\/index.php?rest_route=\/wp\/v2\/posts\/564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lolife.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lolife.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lolife.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lolife.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=564"}],"version-history":[{"count":2,"href":"https:\/\/lolife.top\/index.php?rest_route=\/wp\/v2\/posts\/564\/revisions"}],"predecessor-version":[{"id":574,"href":"https:\/\/lolife.top\/index.php?rest_route=\/wp\/v2\/posts\/564\/revisions\/574"}],"wp:attachment":[{"href":"https:\/\/lolife.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lolife.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lolife.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}