{"id":27,"date":"2023-05-02T09:47:41","date_gmt":"2023-05-02T01:47:41","guid":{"rendered":"https:\/\/www.baic18.top\/blog\/?p=27"},"modified":"2023-05-02T09:47:41","modified_gmt":"2023-05-02T01:47:41","slug":"hoof-paper-scissors%e3%80%90usaco-2017-january-contest-bronze%e3%80%91","status":"publish","type":"post","link":"https:\/\/www.n-bc.top\/?p=27","title":{"rendered":"Hoof, Paper, Scissors\u3010USACO 2017 January Contest, Bronze\u3011"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u9898\u76ee\u63cf\u8ff0(Description)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>You have probably heard of the game &#8220;Rock, Paper, Scissors&#8221;. The cows like to play a similar game they call &#8220;Hoof, Paper, Scissors&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The rules of &#8220;Hoof, Paper, Scissors&#8221; are simple. Two cows play against each-other. They both count to three and then each simultaneously makes a gesture that represents either a hoof, a piece of paper, or a pair of scissors. Hoof beats scissors (since a hoof can smash a pair of scissors), scissors beats paper (since scissors can cut paper), and paper beats hoof (since the hoof can get a papercut). For example, if the first cow makes a &#8220;hoof&#8221; gesture and the second a &#8220;paper&#8221; gesture, then the second cow wins. Of course, it is also possible to tie, if both cows make the same gesture.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Farmer John watches in fascination as two of his cows play a series of N games of &#8220;Hoof, Paper, Scissors&#8221; (1\u2264N\u2264100). Unfortunately, while he can see that the cows are making three distinct types of gestures, he can&#8217;t tell which one represents &#8220;hoof&#8221;, which one represents &#8220;paper&#8221; and which one represents &#8220;scissors&#8221; (to Farmer John&#8217;s untrained eye, they all seem to be variations on &#8220;hoof&#8221;&#8230;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not knowing the meaning of the three gestures, Farmer John assigns them numbers 1, 2, and 3. Perhaps gesture 1 stands for &#8220;hoof&#8221;, or maybe it stands for &#8220;paper&#8221;; the meaning is not clear to him. Given the gestures made by both cows over all N games, please help Farmer John determine the maximum possible number of games the first cow could have possibly won, given an appropriate mapping between numbers and their respective gestures.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u53ef\u80fd\u542c\u8bf4\u8fc7\u201c\u77f3\u5934\u3001\u5e03\u3001\u526a\u5200\u201d\u6e38\u620f\u3002\u5976\u725b\u559c\u6b22\u73a9\u4e00\u79cd\u7c7b\u4f3c\u7684\u6e38\u620f\uff0c\u4ed6\u4eec\u79f0\u4e4b\u4e3a\u201c\u8e44\u5b50\u3001\u5e03\u3001\u526a\u5200\u201d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6e38\u620f\u7684\u89c4\u5219\u5f88\u7b80\u5355\u3002\u4e24\u5934\u6bcd\u725b\u4e92\u76f8\u73a9\u800d\u3002\u4ed6\u4eec\u90fd\u6570\u5230\u4e09\uff0c\u7136\u540e\u6bcf\u4e2a\u4eba\u540c\u65f6\u505a\u4e00\u4e2a\u624b\u52bf\uff0c\u8868\u793a\u4e00\u53ea\u8e44\u5b50\u3001\u4e00\u5f20\u7eb8\u6216\u4e00\u628a\u526a\u5200\u3002\u8e44\u5b50\u6253\u8d25\u526a\u5200\uff08\u56e0\u4e3a\u8e44\u5b50\u53ef\u4ee5\u6253\u788e\u526a\u5200\uff09\uff0c\u526a\u5200\u6253\u8d25\u7eb8\uff08\u56e0\u4e3a\u526a\u5200\u53ef\u4ee5\u526a\u7eb8\uff09\uff0c\u7eb8\u6253\u8d25\u8e44\u5b50\uff08\u56e0\u4e3a\u7eb8\u5305\u88f9\u8e44\u5b50\uff09\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7b2c\u4e00\u5934\u725b\u505a\u51fa\u201c\u8e44\u5b50\u201d\u624b\u52bf\uff0c\u7b2c\u4e8c\u5934\u725b\u505a\u51fa\u201c\u7eb8\u201d\u624b\u52bf\uff0c\u90a3\u4e48\u7b2c\u4e8c\u5934\u725b\u83b7\u80dc\u3002\u5f53\u7136\uff0c\u5982\u679c\u4e24\u5934\u6bcd\u725b\u505a\u51fa\u76f8\u540c\u7684\u59ff\u52bf\uff0c\u4e5f\u53ef\u4ee5\u6253\u5e73\u5c40\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u519c\u592b\u7ea6\u7ff0\u7740\u8ff7\u5730\u770b\u7740\u4ed6\u7684\u4e24\u53ea\u6bcd\u725b\u73a9\u4e00\u7cfb\u5217\u7684\u201c\u8e44\u5b50\u3001\u5e03\u3001\u526a\u5200\u201d\u6e38\u620f\uff081\uff09\u2264N\u2264100). \u4e0d\u5e78\u7684\u662f\uff0c\u867d\u7136\u4ed6\u80fd\u770b\u5230\u5976\u725b\u5728\u505a\u4e09\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u624b\u52bf\uff0c\u4f46\u4ed6\u4e0d\u77e5\u9053\u54ea\u4e00\u79cd\u4ee3\u8868\u201c\u8e44\u201d\uff0c\u54ea\u4e00\u79cd\u4ee3\u8868\u201c\u7eb8\u201d\uff0c\u54ea\u4e00\u79cd\u4ee3\u8868\u201c\u526a\u5200\u201d\uff08\u5728\u519c\u592b\u7ea6\u7ff0\u672a\u7ecf\u8bad\u7ec3\u7684\u773c\u91cc\uff0c\u5b83\u4eec\u4f3c\u4e4e\u90fd\u662f\u201c\u8e44\u201d\u7684\u53d8\u4f53\u2026\u2026\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7531\u4e8e\u4e0d\u77e5\u9053\u8fd9\u4e09\u4e2a\u624b\u52bf\u7684\u610f\u601d\uff0c\u519c\u592b\u7ea6\u7ff0\u7ed9\u4ed6\u4eec\u5206\u914d\u4e86\u6570\u5b571\u30012\u548c3\u3002\u53ef\u80fd\u624b\u52bf1\u4ee3\u8868\u201c\u8e44\u5b50\u201d\uff0c\u4e5f\u53ef\u80fd\u4ee3\u8868\u201c\u7eb8\u201d\uff1b\u4ed6\u7684\u610f\u601d\u4e0d\u6e05\u695a\u3002\u8003\u8651\u5230\u4e24\u5934\u6bcd\u725b\u5728\u6240\u6709N\u573a\u6bd4\u8d5b\u4e2d\u505a\u51fa\u7684\u624b\u52bf\uff0c\u8bf7\u5e2e\u52a9\u519c\u592b\u7ea6\u7ff0\u786e\u5b9a\u7b2c\u4e00\u5934\u6bcd\u725b\u53ef\u80fd\u8d62\u5f97\u7684\u6700\u5927\u6e38\u620f\u6570\uff0c\u7ed9\u51fa\u6570\u5b57\u548c\u5b83\u4eec\u5404\u81ea\u624b\u52bf\u4e4b\u95f4\u7684\u9002\u5f53\u6620\u5c04\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u683c\u5f0f(Format Input)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The first line of the input file contains N.<br>Each of the remaining N lines contain two integers (each 1, 2, or 3), describing a game from Farmer John&#8217;s perspective.<br>\u8f93\u5165\u6587\u4ef6\u7684\u7b2c\u4e00\u884c\u5305\u542bN\u3002<br>\u5269\u4e0b\u7684N\u884c\u4e2d\u7684\u6bcf\u4e00\u884c\u90fd\u5305\u542b\u4e24\u4e2a\u6574\u6570\uff08\u5206\u522b\u4e3a1\u30012\u62163\uff09\uff0c\u4ece\u519c\u592b\u7ea6\u7ff0\u7684\u89d2\u5ea6\u63cf\u8ff0\u4e86\u4e00\u573a\u6e38\u620f\u3002<br>\u8f93\u51fa\u683c\u5f0f(Format Output)<br>Print the maximum number of games the first of the two cows could possibly have won.<br>\u6253\u5370\u4e24\u5934\u6bcd\u725b\u4e2d\u7b2c\u4e00\u5934\u53ef\u80fd\u8d62\u5f97\u7684\u6700\u5927\u6e38\u620f\u6570\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u6837\u4f8b(Sample Input)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>5<br>1 2<br>2 2<br>1 3<br>1 1<br>3 2<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u51fa\u6837\u4f8b(Sample Output)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>2<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bf4\u660e\/\u63d0\u793a(Hint)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>One solution (of several) for this sample case is to have 1 represent &#8220;scissors&#8221;, 2 represent &#8220;hoof&#8221;, and 3 represent &#8220;paper&#8221;. This assignment gives 2 victories to the first cow (&#8220;1 3&#8221; and &#8220;3 2&#8221;). No other assignment leads to more victories.<br>\u5bf9\u4e8e\u8fd9\u4e2a\u793a\u4f8b\u6848\u4f8b\uff0c\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\u662f1\u4ee3\u8868\u201c\u526a\u5200\u201d\uff0c2\u4ee3\u8868\u201c\u8e44\u5b50\u201d\uff0c3\u4ee3\u8868\u201c\u7eb8\u201d\u3002\u8fd9\u9879\u4efb\u52a1\u7ed9\u7b2c\u4e00\u5934\u725b\u4e24\u6b21\u80dc\u5229\uff08\u201c1 3\u201d\u548c\u201c3 2\u201d\uff09\u3002\u6ca1\u6709\u5176\u4ed6\u4efb\u52a1\u80fd\u5e26\u6765\u66f4\u591a\u7684\u80dc\u5229\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;bits\/stdc++.h&gt;\nusing namespace std;\nint n,ans1,ans2;\nint fir&#91;1001],sec&#91;1001];\nint main()\n{\n    cin&gt;&gt;n;\n    for(int i=1;i&lt;=n;i++)\n    {\n        cin&gt;&gt;fir&#91;i]&gt;&gt;sec&#91;i];\n    }\n    for(int i=1;i&lt;=n;i++)\n    {\n        if(fir&#91;i]-sec&#91;i]==-1||fir&#91;i]-sec&#91;i]==2)\n        {\n            ans1++;\n        }\n        if(fir&#91;i]-sec&#91;i]==1||fir&#91;i]-sec&#91;i]==-2)\n        {\n            ans2++;\n        }\n    }\n    cout&lt;&lt;max(ans1,ans2);\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0(Description) You have probably heard of the game &#8220;Rock, Paper, Scissors&#8221;. The cows like to play a similar game they call &#8220;Hoof, Paper, Scissors&#8221;. The rules of &#8220;Hoof, Paper, Scissors&#8221; are simple. Two cows play against each-other. They both count to three and then each simultaneously makes a gesture that represents either a hoof, a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.n-bc.top\/?p=27\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Hoof, Paper, Scissors\u3010USACO 2017 January Contest, Bronze\u3011&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,3],"tags":[6,8],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-js","tag-js","tag-bcs","entry"],"_links":{"self":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27"}],"version-history":[{"count":0,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}