{"id":313,"date":"2024-04-27T21:50:57","date_gmt":"2024-04-27T13:50:57","guid":{"rendered":"https:\/\/seanxd.com\/?p=313"},"modified":"2024-04-27T21:50:59","modified_gmt":"2024-04-27T13:50:59","slug":"zerojudge-f634","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-f634\/","title":{"rendered":"ZeroJudge F634: The Return of Soldiers"},"content":{"rendered":"\n\n\n<p class=\"\">\u9945\u982d\u5c71\u6230\u5f79\u6975\u5176\u6158\u70c8\uff0c\u62c2\u66c9\u8ecd\u7e3d\u90e8\u6d3e\u51fa N \u4f4d\u58eb\u5b98\u5175\u9032\u884c\u7e3d\u653b\u64ca\uff0c\u7d93\u904e\u4e03\u5929\u4e03\u591c\u7684\u5f81\u6230\uff0c\u7d42\u65bc\u653b\u4e0b\u4e86\u5c71\u982d\u3002<br>\u5b58\u6d3b\u7684\u58eb\u5b98\u5175\u958b\u59cb\u9678\u7e8c\u8fd4\u56de\u90e8\u968a\u5831\u5230\uff0c\u8ecd\u7e3d\u90e8\u5e0c\u671b\u80fd\u7d71\u8a08\u9019\u5834\u6230\u5f79\u751f\u9084\u7684\u58eb\u5b98\u5175\u60c5\u6cc1\u3002\u7136\u800c\u60c5\u6cc1\u6709\u4e9b\u8907\u96dc\u3002<\/p>\n\n\n\n<p class=\"\">\u58eb\u5b98\u5175\u5206\u5c6c\u4e0d\u540c\u7684\u8ecd\u7a2e\uff1a<strong>\u6d77\u8ecd (navy)\uff1a1\u3001\u9678\u8ecd (army)\uff1a2\u3001\u7a7a\u8ecd (air)\uff1a3<\/strong><br>\u4e14\u8ecd\u968e\u4e0d\u540c\uff1a<strong>\u8ecd\u5b98 (officer)\uff1a1\u3001\u58eb\u5b98 (sergeant)\uff1a2\u3001\u58eb\u5175 (soldier)\uff1a3<\/strong><\/p>\n\n\n\n<p class=\"\">\u58eb\u5b98\u5175\u540c\u4e00\u500b\u4eba\u6709\u91cd\u8907\u767b\u8a18\u7684\u60c5\u6cc1\uff0c\u66f4\u9ebb\u7169\u7684\u662f\u9084\u6709\u540c\u540d\u540c\u59d3\u7684\u4eba (\u82e5<strong>\u59d3\u540d\u3001\u8ecd\u7a2e\u3001\u8ecd\u968e\u90fd\u76f8\u540c\u8005\u8996\u70ba\u540c\u4e00\u500b\u4eba<\/strong>)\uff0c<br>\u8ecd\u7e3d\u90e8\u767c\u73fe\u9019\u500b\u5de5\u4f5c\u662f\u4e4e\u6bd4\u653b\u5c71\u982d\u66f4\u56f0\u96e3\uff0c\u8acb\u5e6b\u5fd9\u5beb\u4e00\u7a0b\u5f0f\u8655\u7406\u9019\u9805\u7d71\u8a08\u4efb\u52d9\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 nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u6e2c\u8cc7\u7b2c\u4e00\u884c\u6709\u5169\u500b\u6574\u6578 N \u548c M<br>(1 &lt;= N, M &lt;= 1000,000)<br>\u7b2c\u4e8c\u884c\u958b\u59cb\u6709 M \u884c\uff0c\u6bcf\u884c\u6709\u5b57\u4e32 S\u3001\u6574\u6578 A \u548c B\uff1a<br>S\uff1a\u59d3\u540d (\u5c0f\u65bc 10 \u500b\u5b57\u5143, &#8216;A&#8217;\uff5e&#8217;Z&#8217; \u69cb\u6210)<br>A\uff1a\u8ecd\u7a2e (\u6d77\u8ecd\uff1a1\u3001\u9678\u8ecd\uff1a2\u3001\u7a7a\u8ecd\uff1a3)<br>B\uff1a\u8ecd\u968e (\u8ecd\u5b98\uff1a1\u3001\u58eb\u5b98\uff1a2\u3001\u58eb\u5175\uff1a3)<\/td><td>\u7b2c\u4e00\u884c\u8f38\u51fa\u5404\u8ecd\u7a2e\u5b58\u6d3b\u4eba\u6578<br>\u7b2c\u4e8c\u884c\u8f38\u51fa\u5404\u8ecd\u968e\u5b58\u6d3b\u4eba\u6578<br>\u7b2c\u4e09\u884c\u8f38\u51fa\u5b58\u6d3b\u4eba\u6578\u767e\u5206\u6bd4 (\u5c0f\u6578\u9ede\u5f8c 1 \u4f4d)<\/td><\/tr><tr><td>15  10<br>ABC  1  2<br>ABC  2  1<br>ABC  2  1<br>ACD  3  3<br>ACD  1  2<br>ACD  1  1<br>BBC  2  1<br>BBC  1  2<br>BBC  1  2<br>BBE  3  3<\/td><td>navy:4 army:2 air:2<br>officer:3 sergeant:3 soldier:2<br>survival rate: 53.3%<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge F634 \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 class=\"\">\u4f7f\u7528 <strong>Map<\/strong> \u4f86\u5224\u65b7\u6bcf\u4e00\u500b\u4eba\u662f\u5426\u5df2\u7d93\u767b\u8a18\u904e\u4e86\uff0c\u4e26\u4e14\u7528 <strong>Map<\/strong> \u4f86\u7d00\u9304\u6bcf\u4e00\u500b\u8ecd\u7a2e\u53ca\u8ecd\u968e\u7684\u4eba\u6578\u3002<\/p>\n\n\n\n<p class=\"\">Map \u7684 Key \u503c\u8a2d\u5b9a\u70ba Pair&lt;string, Pair&lt;int, int>>\uff0c\u88e1\u9762\u5206\u5225\u5b58 S\u3001A\u3001B\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=f634\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge F634: \u58eb\u5175\u6b78\u4f86<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;map&gt;\n#include &lt;stdio.h&gt;\nusing namespace std;\n\npair&lt;string, pair&lt;int, int&gt;&gt; rtn (string name, int a, int b)\n{\n    pair&lt;string, pair&lt;int, int&gt;&gt;tmp;\n    tmp.first = name;\n    pair&lt;int, int&gt;aa;\n    aa.first = a;\n    aa.second = b;\n    tmp.second = aa;\n    return tmp;\n}\n\nint main() {\n    int N, M;\n    cin &gt;&gt; N &gt;&gt; M;\n    map&lt;pair&lt;string, pair&lt;int, int&gt;&gt;, int&gt;person;\n    map&lt;int, int&gt;type;\n    map&lt;int, int&gt;level;\n    double survive = 0;\n    for (int i = 0; i&lt;M; i++)\n    {\n        string name;\n        int a, b;\n        cin &gt;&gt; name &gt;&gt; a &gt;&gt; b;\n        if (person[rtn(name, a, b)] == 0)\n        {\n            type[a]++;\n            level[b]++;\n            survive++;\n        }\n        person[rtn(name, a, b)]++;\n    }\n    cout &lt;&lt; &quot;navy:&quot; &lt;&lt; type[1] &lt;&lt; &quot; army:&quot; &lt;&lt; type[2] &lt;&lt; &quot; air:&quot; &lt;&lt; type[3] &lt;&lt; &quot;\\n&quot;;\n    cout &lt;&lt; &quot;officer:&quot; &lt;&lt; level[1] &lt;&lt; &quot; sergeant:&quot; &lt;&lt; level[2] &lt;&lt; &quot; soldier:&quot; &lt;&lt; level[3] &lt;&lt; &quot;\\n&quot;;\n    double total = double(N);\n    printf(&quot;survival rate: %.1f&quot;, survive\/total*100);\n    cout &lt;&lt; &quot;%\\n&quot;;\n}\n\n\/\/ZeroJudge F634\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u9945\u982d\u5c71\u6230\u5f79\u6975\u5176\u6158\u70c8\uff0c\u62c2\u66c9\u8ecd\u7e3d\u90e8\u6d3e\u51fa N \u4f4d\u58eb\u5b98\u5175\u9032\u884c\u7e3d\u653b\u64ca\uff0c\u7d93\u904e\u4e03\u5929\u4e03\u591c\u7684\u5f81\u6230\uff0c\u7d42\u65bc\u653b\u4e0b\u4e86\u5c71\u982d\u3002\u5b58\u6d3b\u7684\u58eb\u5b98\u5175\u958b [&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":[6],"tags":[14,23,8,11,7,9],"class_list":["post-313","post","type-post","status-publish","format-standard","hentry","category-6","tag-map","tag-pair","tag-8","tag-11","tag-7","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/313","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=313"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/313\/revisions"}],"predecessor-version":[{"id":315,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/313\/revisions\/315"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}