{"id":771,"date":"2024-07-16T09:00:00","date_gmt":"2024-07-16T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=771"},"modified":"2024-06-06T18:00:58","modified_gmt":"2024-06-06T10:00:58","slug":"zerojudge-h026","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-h026\/","title":{"rendered":"ZeroJudge H026: Rock, paper, scissors!"},"content":{"rendered":"\n\n\n<p>\u5e7c\u7a1a\u5712\u7684\u7d72\u7d72\u5f88\u559c\u6b61\u8ddf\u54e5\u54e5\u73a9\u731c\u62f3\uff0c\u56e0\u70ba\u9019\u662f\u4ed6\u5c11\u6578\u6709\u6a5f\u6703\u8d0f\u54e5\u54e5\u7684\u904a\u6232\u3002\u6bcf\u5929\u53ea\u8981\u4e00\u56de\u5bb6\uff0c\u7d72\u7d72\u5c31\u8981\u54e5\u54e5\u966a\u4ed6\u731c\u62f3\u3002<br>\u70ba\u4e86\u6230\u52dd\u54e5\u54e5\uff0c\u7d72\u7d72\u6bcf\u5929\u5728\u5e7c\u7a1a\u5712\u6642\u90fd\u6703\u82b1\u597d\u591a\u6642\u9593\u7814\u7a76\u51fa\u62f3\u7684\u7b56\u7565\uff0c\u4e26\u5c07\u9810\u8a08\u8981\u51fa\u7684\u62f3\u5beb\u5728\u7d19\u4e0a<br>\u4f46\u662f\u54e5\u54e5\u4e0a\u4e86\u570b\u4e2d\u4ee5\u5f8c\u529f\u8ab2\u8d8a\u4f86\u8d8a\u591a\uff0c\u6c92\u6709\u7a7a\u5148\u601d\u8003\u8981\u51fa\u4ec0\u9ebc\u62f3\uff0c\u65bc\u662f\u54e5\u54e5\u6c7a\u5b9a\u6839\u64da\u7d72\u7d72\u51fa\u7684\u62f3\u4f86\u6c7a\u5b9a\u8a72\u5982\u4f55\u51fa\u62f3\u3002<\/p>\n\n\n\n<p>\u6bcf\u5929\u54e5\u54e5<strong>\u53ea\u8981\u6c7a\u5b9a\u7b2c\u4e00\u6b21\u731c\u62f3\u7684\u72c0\u6cc1 F<\/strong>\uff0c\u63a5\u4e0b\u4f86\u4ed6\u7684\u731c\u62f3\u7b56\u7565\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u7d72\u7d72<strong>\u9023\u7e8c\u5169\u8f2a\u51fa\u4e86\u4e00\u6a23\u7684\u62f3\uff0c\u4e0b\u4e00\u8f2a\u4ed6\u5c31\u6703\u51fa\u6253\u6557\u7d72\u7d72\u524d\u5169\u8f2a\u7684\u62f3<\/strong>\u3002<\/li>\n\n\n\n<li>\u5426\u5247\uff0c<strong>\u4ed6\u4e0b\u4e00\u8f2a\u6703\u51fa\u8ddf\u7d72\u7d72\u524d\u4e00\u8f2a\u4e00\u6a23\u7684\u62f3<\/strong>\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8acb\u4f60\u5beb\u4e00\u500b\u7a0b\u5f0f\u6a21\u64ec\u5169\u4eba\u904a\u6232\u904e\u7a0b\u8207\u7d50\u679c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u7b2c\u4e00\u884c\u8f38\u5165\u54e5\u54e5\u7b2c\u4e00\u8f2a\u8981\u51fa\u7684\u62f3 F\u3002<br>\u7b2c\u4e8c\u884c\u8f38\u5165\u59b9\u59b9\u6e96\u5099\u7684\u6578\u91cf N\u3002<br>\u7b2c\u4e09\u884c\u4f9d\u5e8f\u8f38\u5165\u59b9\u59b9\u6e96\u5099\u51fa\u7684\u62f3 y<sub>1<\/sub>\u3001y<sub>2<\/sub>\u3001\u2026 \u3001y<sub>N<\/sub>\uff0c\u4ee5\u7a7a\u683c\u9694\u958b\u3002<\/td><td>\u8f38\u51fa\u6709\u4e00\u884c\uff0c<strong>\u4f9d\u5e8f\u8f38\u51fa\u54e5\u54e5\u6bcf\u4e00\u56de\u5408\u731c\u7684\u62f3\uff0c\u4ee5\u7a7a\u683c\u9694\u958b<\/strong>\u3002\u4e26\u5728\u5192\u865f\u5f8c\u8f38\u51fa\u7b2c\u5e7e\u56de\u5408\u5206\u51fa\u52dd\u8ca0\u3002<br><br>\u82e5\u5728\u7b2c k \u8f2a\u6642\u54e5\u54e5\u8d0f\u4e86\uff0c\u8f38\u51fa\u300cWon at round k\u300d<br>\u82e5\u5728\u7b2c k \u8f2a\u6642\u54e5\u54e5\u8f38\u4e86\uff0c\u8f38\u51fa\u300cLost at round k\u300d<br>\u82e5\u6bd4\u5b8c N \u8f2a\u4ecd\u7136\u5e73\u624b\uff0c\u8f38\u51fa\u300cDrew at round N\u300d<\/td><\/tr><tr><td>0<br>4<br>2 5 0 2<\/td><td>0 : Won at round 1<\/td><\/tr><tr><td>2<br>2<br>2 0<\/td><td>2 2 : Lost at round 2<\/td><\/tr><tr><td>5<br>4<br>5 5 0 0<\/td><td>5 5 2 : Lost at round 3<\/td><\/tr><tr><td>5<br>6<br>5 5 2 2 0 0<\/td><td>5 5 2 2 0 0 : Drew at round 6<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge H026 \u7bc4\u4f8b\u6e2c\u8cc7<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u9700\u8981\u5c07\u59b9\u59b9\u731c\u7684\u62f3\u6536\u5230\u4e00\u500b\u9663\u5217\u4e2d\u4f86\u5224\u65b7\u6bcf\u4e00\u6b21\u54e5\u54e5\u8981\u51fa\u7684\u62f3\uff0c\u6536\u6578\u5217\u7684\u6642\u5019\u5224\u65b7\u76ee\u524d\u6536\u5230\u7b2c\u5e7e\u500b\u6578\u5b57\uff0c\u5982\u679c\u6536\u5230\u7b2c\u4e8c\u500b\u6578\u5b57\uff0c\u5247\u54e5\u54e5\u51fa\u7684\u62f3\u70ba\u7b2c\u4e00\u500b\u6578\u5b57\uff0c\u5982\u679c\u662f\u7b2c\u4e8c\u500b\u4ee5\u5f8c\u7684\u6578\u5b57\uff0c\u5247\u5224\u65b7\u524d\u5169\u500b\u6578\u5b57\u662f\u5426\u76f8\u540c\u3002<\/p>\n\n\n\n<p>\u53ea\u8981\u6709\u8f38\u6216\u662f\u8d0f\u51fa\u73fe\uff0c\u904a\u6232\u5c31\u6703\u7d50\u675f\uff0c\u5f8c\u9762\u7684\u8cc7\u6599\u4e0d\u6703\u7528\u5230\uff0c\u4f46\u662f\u9084\u662f\u8981\u9032\u884c\u8f38\u5165\uff0c\u6240\u4ee5\u53ef\u4ee5\u5ba3\u544a\u4e00\u500b\u5e03\u6797\u503c finish \u9810\u8a2d\u70ba false\uff0c\u5982\u679c\u6709\u8f38\u8d0f\u51fa\u73fe\u5247\u5c07 finish \u8a2d\u5b9a\u70ba true\uff0c\u5728 For\u8ff4\u5708 \u4e2d\u7684\u6bcf\u4e00\u6b21\u6536\u8cc7\u6599\u4e4b\u5f8c\u5224\u65b7\uff0c\u5982\u679c finish == true \u5247 continue \u4e0d\u505a\u5f8c\u9762\u7684\u5224\u65b7\u3002<\/p>\n\n\n\n<p>\u56e0\u70ba\u4e5f\u662f\u6703\u6709\u6c38\u9060\u5e73\u624b\u7684\u60c5\u6cc1\uff0c\u6240\u4ee5\u5728 For\u8ff4\u5708 \u7d50\u675f\u4e4b\u5f8c\u8981\u5224\u65b7 finish \u662f\u5426\u70ba true\uff0c\u5982\u679c !finish \u5247\u4ee3\u8868\u9084\u6c92\u6709\u5206\u51fa\u52dd\u8ca0\uff0c\u5247\u8981\u8f38\u51fa \u300cDrew at round N\u300d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=h026\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge H026: \u731c\u62f3<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;map&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int F, N;\n    cin &gt;&gt; F &gt;&gt; N;\n    vector&lt;int&gt;num;\n    map&lt;int, int&gt;MAP;\n    MAP[0] = 5;\n    MAP[2] = 0;\n    MAP[5] = 2;\n    bool finish = false;\n    for (int i = 0; i&lt;N; i++) {\n        int tmp;\n        cin &gt;&gt; tmp;\n        if (finish) continue;\n        num.push_back(tmp);\n        if (i == 1) F = num[0];\n        else if (i &gt; 1) {\n            if (num[i-2] == num[i-1]) F = MAP[num[i-2]];\n            else F = num[i-1];\n        }\n        cout &lt;&lt; F &lt;&lt; &quot; &quot;;\n        if ((F == 0 && tmp == 5) || (F == 2 && tmp == 0) || (F == 5 && tmp == 2)) {\n            cout &lt;&lt; &quot;: Lost at round &quot; &lt;&lt; i+1 &lt;&lt; &quot;\\n&quot;;\n            finish = true;\n            continue;\n        }\n        if ((F == 0 && tmp == 2) || (F == 2 && tmp == 5) || (F == 5 && tmp == 0)) {\n            cout &lt;&lt; &quot;: Won at round &quot; &lt;&lt; i+1 &lt;&lt; &quot;\\n&quot;;\n            finish = true;\n        }\n    }\n    if (!finish) cout &lt;&lt; &quot;: Drew at round &quot; &lt;&lt; N &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge H026\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5e7c\u7a1a\u5712\u7684\u7d72\u7d72\u5f88\u559c\u6b61\u8ddf\u54e5\u54e5\u73a9\u731c\u62f3\uff0c\u56e0\u70ba\u9019\u662f\u4ed6\u5c11\u6578\u6709\u6a5f\u6703\u8d0f\u54e5\u54e5\u7684\u904a\u6232\u3002\u6bcf\u5929\u53ea\u8981\u4e00\u56de\u5bb6\uff0c\u7d72\u7d72\u5c31\u8981\u54e5\u54e5\u966a\u4ed6\u731c\u62f3\u3002\u70ba\u4e86\u6230 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[25],"tags":[14,20,8,34,9],"class_list":["post-771","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-map","tag-20","tag-8","tag-34","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=771"}],"version-history":[{"count":3,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/771\/revisions"}],"predecessor-version":[{"id":774,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/771\/revisions\/774"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}