{"id":44,"date":"2025-02-12T22:35:18","date_gmt":"2025-02-12T14:35:18","guid":{"rendered":"https:\/\/liyongquan.cn\/?p=44"},"modified":"2025-02-16T22:40:25","modified_gmt":"2025-02-16T14:40:25","slug":"cf1004-div2-b","status":"publish","type":"post","link":"https:\/\/liyongquan.cn\/?p=44","title":{"rendered":"cf1004.div2.B"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/codeforces.com\/contest\/2067\/problem\/B\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/codeforces.com\/contest\/2067\/problem\/B<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:16px\"><code>#include&lt;bits\/stdc++.h&gt;\nusing namespace std;\nint t,n;\n\nint x,a&#91;1005],sta&#91;1005],stb&#91;1005];\nint main(){\n\t\/\/freopen(\"in.txt\",\"r\",stdin); \n\t\/\/freopen(\"out.txt\",\"w\",stdout); \n\tcin&gt;&gt;t;\n\twhile(t--){\n\t\t\n\t\tcin&gt;&gt;n;\n\t\tfor(int i=1 ;i&lt;=n;i++){\n\t\t\tcin&gt;&gt;a&#91;i];\n\t\t\tsta&#91;a&#91;i]]++;\n\t\t}\n\t\t\n\t\tfor(int i=1;i&lt;=n;i++){\n\t\t\tif(sta&#91;i]&gt;=2){\n\t\t\t\tsta&#91;i]--;\n\t\t\t\tstb&#91;i]++;\n\t\t\t}\n\t\t\tif(sta&#91;i]){\n\t\t\t\t\n\t\t\t\tsta&#91;i+1]=sta&#91;i+1]+sta&#91;i]-1;\n\t\t\t\tsta&#91;i]=1;\n\t\t\t}<sup data-fn=\"bdbf8e9b-491a-42ca-bebd-eed8c8db38ca\" class=\"fn\"><a href=\"#bdbf8e9b-491a-42ca-bebd-eed8c8db38ca\" id=\"bdbf8e9b-491a-42ca-bebd-eed8c8db38ca-link\">1<\/a><\/sup>\n\t\t}\n\n\t\tfor(int i =1;i&lt;=n;i++){\n\t\t\tif((sta&#91;i]+stb&#91;i])%2!=0)\tx=1;\n\t\t}\t\n\t\t\n\t\tif(x==1)cout&lt;&lt;\"No\"&lt;&lt;endl;\n\t\telse cout&lt;&lt;\"Yes\"&lt;&lt;endl;\n\t\t memset(a,0,sizeof(a));\n\t\t memset(sta,0,sizeof(sta));\n\t\t memset(stb,0,sizeof(stb));<sup data-fn=\"63935274-0f52-4574-b7fa-47437a5e237b\" class=\"fn\"><a href=\"#63935274-0f52-4574-b7fa-47437a5e237b\" id=\"63935274-0f52-4574-b7fa-47437a5e237b-link\">2<\/a><\/sup>\n\t\t x=0;\n\t}\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:17px\">  \u672c\u9898\u4e3b\u8981\u91c7\u7528\u8d2a\u5fc3\u7b97\u6cd5\uff0c\u5148sta\u8bb0\u5f55\u6bcf\u4e2a\u6709\u4ef7\u503c\u7684\u7269\u54c1\u4e2a\u6570\uff0c\u6392\u5e8f\u540e\u4ece\u6700\u5c0f\u4ef7\u503c\u5f00\u59cb\u64cd\u4f5c<br>  \u5148\u5411\u7b2c\u4e8c\u80cc\u5305\u8f6c\u79fb\u7269\u54c1\uff0c\u4fdd\u8bc1\u8be5\u4ef7\u503c\u7b26\u5408\u6761\u4ef6\u540e\u5411\u9ad8\u4ef7\u503c\u8f6c\u5316\uff0c\u76f4\u5230\u5269\u4f59\u7269\u54c1\u4e0d\u591f\u8f6c\u5316\uff08\u8be5\u6cd5\u7531\u4e8e\u6570\u636e\u8303\u56f4\u8f83\u5c0f\u53ef\u4ee5\u901a\u8fc7\uff09\uff0c\u6700\u540e\u5224\u65ad\u6bcf\u4e2a\u4ef7\u503c\u4e0b\u4e24\u4e2a\u80cc\u5305\u4e2d\u7684\u7269\u54c1\u662f\u5426\u5747\u5206\u5373\u53ef\uff08\u53ef\u4ee5\u4f18\u5316\uff0c\u56e0\u4e3a\u4ece\u6700\u5c0f\u4ef7\u503c\u5f00\u59cb\u64cd\u4f5c\uff0c\u5373\u53ea\u9700\u8bb0\u5f55\u5e76\u5224\u65ad\u6700\u540e\u4e00\u4e2a\u4ef7\u503c\u5b58\u5728\u7684\u7269\u54c1\u5373\u53ef\uff0c\u7531\u4e8e\u672c\u9898\u6570\u636e\u8f83\u5c0f\u4fbf\u4e0d\u5728\u4f18\u5316<sup data-fn=\"7f0d5f08-fca5-4c99-aed4-8135713b08f8\" class=\"fn\"><a href=\"#7f0d5f08-fca5-4c99-aed4-8135713b08f8\" id=\"7f0d5f08-fca5-4c99-aed4-8135713b08f8-link\">3<\/a><\/sup>\uff09<\/p>\n\n\n<ol class=\"wp-block-footnotes\"><li id=\"bdbf8e9b-491a-42ca-bebd-eed8c8db38ca\">if(sta[i]==0&amp;&amp;sta[i-1]!=0){<br>    flag = 1;<br>    break;\/\/i==1e9;<br>} <a href=\"#bdbf8e9b-491a-42ca-bebd-eed8c8db38ca-link\" aria-label=\"\u8df3\u8f6c\u5230\u811a\u6ce8\u5f15\u7528 1\">\u21a9\ufe0e<\/a><\/li><li id=\"63935274-0f52-4574-b7fa-47437a5e237b\">\u6ce8\u610f\u6bcf\u4e2a\u6d4b\u8bd5\u70b9\u8ba1\u7b97\u5b8c\u540e\u8981\u91cd\u65b0\u521d\u59cb\u5316\u6570\u7ec4 <a href=\"#63935274-0f52-4574-b7fa-47437a5e237b-link\" aria-label=\"\u8df3\u8f6c\u5230\u811a\u6ce8\u5f15\u7528 2\">\u21a9\ufe0e<\/a><\/li><li id=\"7f0d5f08-fca5-4c99-aed4-8135713b08f8\">\u4f18\u5316\u53ef\u4ee5\u57281\u5904 <a href=\"#7f0d5f08-fca5-4c99-aed4-8135713b08f8-link\" aria-label=\"\u8df3\u8f6c\u5230\u811a\u6ce8\u5f15\u7528 3\">\u21a9\ufe0e<\/a><\/li><\/ol>","protected":false},"excerpt":{"rendered":"<p>https:\/\/codeforces.com\/contest\/2067\/problem\/B \u672c\u9898\u4e3b\u8981\u91c7\u7528\u8d2a\u5fc3\u7b97 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"[{\"content\":\"if(sta[i]==0&amp;&amp;sta[i-1]!=0){<br>    flag = 1;<br>    break;\/\/i==1e9;<br>}\",\"id\":\"bdbf8e9b-491a-42ca-bebd-eed8c8db38ca\"},{\"content\":\"\u6ce8\u610f\u6bcf\u4e2a\u6d4b\u8bd5\u70b9\u8ba1\u7b97\u5b8c\u540e\u8981\u91cd\u65b0\u521d\u59cb\u5316\u6570\u7ec4\",\"id\":\"63935274-0f52-4574-b7fa-47437a5e237b\"},{\"content\":\"\u4f18\u5316\u53ef\u4ee5\u57281\u5904\",\"id\":\"7f0d5f08-fca5-4c99-aed4-8135713b08f8\"}]"},"categories":[4],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/liyongquan.cn\/index.php?rest_route=\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liyongquan.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/liyongquan.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/liyongquan.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/liyongquan.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=44"}],"version-history":[{"count":16,"href":"https:\/\/liyongquan.cn\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":84,"href":"https:\/\/liyongquan.cn\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions\/84"}],"wp:attachment":[{"href":"https:\/\/liyongquan.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/liyongquan.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/liyongquan.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}