{"id":481,"date":"2024-05-15T09:00:00","date_gmt":"2024-05-15T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=481"},"modified":"2024-05-04T10:30:46","modified_gmt":"2024-05-04T02:30:46","slug":"zerojudge-h075","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-h075\/","title":{"rendered":"ZeroJudge H075: \u6210\u7e3e\u6392\u540d"},"content":{"rendered":"\n\n\n<p class=\"\">\u96fb\u5b50\u8a08\u7b97\u6a5f\u7814\u7a76\u793e\u8981\u4f86\u793e\u8003\u4e86\u5594:D\uff0c\u7e3d\u5171\u8981\u8003 3 \u79d1\uff0c\u5206\u5225\u662f<strong>\u8cc7\u8a0a\u3001\u6578\u5b78\u3001\u82f1\u6587<\/strong>\uff0c\u6bcf\u5230\u9019\u500b\u8003\u8a66\u7684\u5b63\u7bc0\uff0c\u793e\u5718\u5167\u7e3d\u662f\u6703\u5145\u6eff\u8457\u7af6\u722d\u7684\u5473\u9053\uff0c\u800c\u5728\u9019\u500b\u793e\u5718\uff0c\u6709\u8457\u7279\u5225\u7684\u6210\u7e3e\u52a0\u6b0a\uff0c<\/p>\n\n\n\n<p class=\"\"><strong>\u8cc7\u8a0a\u6210\u7e3e\u5fc5\u9808\u4e58\u4ee5 5\uff0c\u6578\u5b78\u5247\u662f\u4e58\u4ee5 3\uff0c\u82f1\u6587\u4e58\u4ee5 2<\/strong>\uff0c\u6700\u5f8c\u53d6\u52a0\u6b0a\u5e73\u5747\uff0c<\/p>\n\n\n\n<p class=\"\">\u82e5\u9047<strong>\u540c\u5206\u5247\u4f9d\u7167\u8cc7\u8a0a\u3001\u6578\u5b78\u3001\u82f1\u6587\u7684\u9806\u5e8f\u9032\u884c\u6bd4\u8f03 (\u82e5\u7686\u540c\u5206\u5247\u5ea7\u865f\u5c0f\u7684\u5728\u524d\u9762)<\/strong>\uff0c\u73fe\u5728\u8acb\u4f60\u5e6b\u5fd9\u96fb\u5b50\u8a08\u7b97\u6a5f\u7814\u7a76\u793e\u6392\u540d\u5427\uff01<\/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>\u8f38\u5165\u4e00\u500b\u6574\u6578 N\uff0c\u4ee3\u8868\u6709 N \u4f4d\u5b78\u751f\u53c3\u52a0\u8003\u8a66\uff0c\u63a5\u8457\u6709 N \u884c\u8f38\u5165\uff0c\u6bcf\u884c\u8f38\u5165\u6709 4 \u500b\u6574\u6578A<sub>1<\/sub>\u3001A<sub>2<\/sub>\u3001A<sub>3<\/sub>\u3001A<sub>4<\/sub>\uff0c\u5206\u5225\u4ee3\u8868\u5b78\u751f\u7684\u5ea7\u865f\u3001\u8cc7\u8a0a\u6210\u7e3e\u3001\u6578\u5b78\u6210\u7e3e\u3001\u82f1\u6587\u6210\u7e3e\u3002<\/td><td><strong>\u8f38\u51fa\u6210\u7e3e\u7531\u9ad8\u5230\u4f4e\u6392\u5217\u904e\u7684\u5b78\u751f\u5ea7\u865f\u4ee5\u53ca\u5e73\u5747<\/strong>\uff0c\u6bcf\u8f38\u51fa\u4e00\u4f4d\u5b78\u751f\u5373\u63db\u884c\u3002<\/td><\/tr><tr><td>7<br>1  60  80  50<br>2  80  40  90<br>3  50  70  80<br>4  60  80  70<br>5  100  20  20<br>6  60  40  100<br>7  60  80  50<\/td><td>2 70<br>4 68<br>1 64<br>7 64<br>6 62<br>3 62<br>5 60<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge H075 \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\u6574\u6578\u4f86\u6536\u5ea7\u865f\u548c\u4e09\u500b\u6210\u7e3e\uff0c\u7136\u5f8c\u8a08\u7b97\u52a0\u6b0a\u7684\u5e73\u5747\u3002<strong>\u7b97\u6cd5\u662f\u300c[(\u8cc7\u8a0a*5) + (\u6578\u5b78*3) + (\u82f1\u6587*2)] \/ (5 + 3 + 2)\u300d<\/strong>\u3002<strong>\u8a08\u7b97\u5e73\u5747\u7684\u6642\u5019\u9700\u8981\u8a08\u7b97\u6210\u6d6e\u9ede\u6578<\/strong>\uff0c\u8a18\u5f97\u8981\u5c07\u6210\u7e3e\u5148\u8f49\u578b\u518d\u8a08\u7b97\u3002<\/p>\n\n\n\n<p class=\"\">\u5ba3\u544a\u4e00\u500b Vector&lt;Vector&lt;float>>\uff0c\u4f7f\u7528\u4e8c\u7dad\u9663\u5217\u4f86\u505a\u6392\u5e8f\uff0c<strong>\u6bcf\u4e00\u500b\u4eba\u5c31\u662f\u4e00\u500b Vector&lt;float><\/strong>\u3002\u5728\u6536\u5230\u8cc7\u6599\u4e4b\u5f8c\u5c07\u4ee5\u4e0b\u7684\u8cc7\u6599\u4f9d\u5e8f Push_Back \u5230 Vector&lt;float> \u4e2d\uff1a\u52a0\u6b0a\u5e73\u5747 (\u6d6e\u9ede\u6578)\u3001\u8cc7\u8a0a\u6210\u7e3e (\u6574\u6578)\u3001\u6578\u5b78\u6210\u7e3e (\u6574\u6578)\u3001\u82f1\u6587\u6210\u7e3e (\u6574\u6578)\u3001\u5ea7\u865f\uff0a-1\u3002<\/p>\n\n\n\n<p class=\"\">\u5c07\u4e8c\u7dad\u9663\u5217\u6392\u5e8f\u4e4b\u5f8c\u8981\u5f9e\u6700\u53f3\u908a\u8f38\u51fa\u5230\u6700\u5de6\u908a\uff0c\u4f46\u662f\u5982\u679c\u6709\u5168\u90e8\u540c\u5206\u7684\u60c5\u6cc1\uff0c\u5ea7\u865f\u6bd4\u8f03\u5927\u7684\u5c31\u6703\u6392\u5728\u8f03\u53f3\u908a\uff0c<strong>\u5982\u679c\u5b58\u8cc7\u6599\u7684\u6642\u5019\u5c07\u5ea7\u865f\uff0a-1\uff0c\u9019\u6a23\u5b50\u6bd4\u8f03\u5c0f\u7684\u5ea7\u865f\u5c31\u6703\u6392\u5230\u6bd4\u8f03\u53f3\u908a<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u518d\u4f86\u8981\u4f7f\u7528\u4e00\u500b If \u5224\u65b7\u662f\uff0c<strong>\u5224\u65b7\u52a0\u6b0a\u5e73\u5747\u6642\u662f\u5426\u53ef\u4ee5\u6574\u9664<\/strong>\uff0c\u5982\u679c\u53ef\u4ee5\u6574\u9664\u7684\u8a71\uff0c\u62ff\u525b\u525b\u8a08\u7b97\u7684<strong>\u6d6e\u9ede\u6578\u8f49\u63db\u6210\u5b57\u4e32\u7684\u578b\u614b<\/strong>\u3002\u4e26\u4e14\u4f7f\u7528 For\u8ff4\u5708 <strong>\u5c07\u5c0f\u6578\u9ede\u4e4b\u524d (\u4e0d\u5305\u542b\u5c0f\u6578\u9ede) \u7684\u5b57\u5143\u90fd\u52a0\u5230\u4e00\u500b\u65b0\u7684\u5b57\u4e32<\/strong>\u3002\u4f7f\u7528 Map&lt;Vector&lt;float>, string>\uff0cKey \u5c31\u662f\u4ee3\u8868\u76ee\u524d\u9019\u500b\u4eba\u7684 Vector&lt;float>\uff0cValue \u5c31\u662f\u525b\u525b\u76f8\u52a0\u5b8c\u7684\u5b57\u4e32\uff0c\u8981\u7528\u4f86\u8f38\u51fa\u3002<\/p>\n\n\n\n<p class=\"\">Else \u7684\u8a71\u5c31<strong>\u4ee3\u8868\u6c92\u6709\u8fa6\u6cd5\u6574\u9664<\/strong>\uff0c\u5c31\u505a\u8ddf If \u76f8\u540c\u7684\u4e8b\u60c5\uff0c<strong>\u53ea\u662f\u9019\u4e00\u6b21\u8981\u5c07\u5b57\u4e32\u52a0\u5230\u5c0f\u6578\u9ede\u5f8c\u4e00\u4f4d\u7684\u5b57\u5143<\/strong> (\u4e0d\u9700\u8981\u56db\u6368\u4e94\u5165)\u3002<\/p>\n\n\n\n<p class=\"\">\u8f38\u51fa\u7684\u6642\u5019\u8981<strong>\u8a18\u5f97\u5c07\u5ea7\u865f\u518d\u4e58\u4ee5 -1<\/strong>\uff0c\u5e73\u5747\u503c\u7684\u8a71\u5c31\u662f<strong>\u4f7f\u7528 Map[stu[i]]<\/strong> \u4f86\u8f38\u51fa\u525b\u525b\u76f8\u52a0\u597d\u7684\u5b57\u4e32\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=h075\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge H075: \u6210\u7e3e\u6392\u540d<\/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;vector&gt;\n#include &lt;algorithm&gt;\n#include &lt;map&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    cin &gt;&gt; N;\n    vector&lt;vector&lt;float&gt;&gt;stu;\n    map&lt;vector&lt;float&gt;, string&gt;MAP;\n    for (int i = 0; i&lt;N; i++)\n    {\n        vector&lt;float&gt;v;\n        int id, com, math, eng;\n        cin &gt;&gt; id &gt;&gt; com &gt;&gt; math &gt;&gt; eng;\n        float tmp = (float(com*5) + float(math*3) + float(eng*2))\/10.;\n        v.push_back(tmp);\n        v.push_back(com);\n        v.push_back(math);\n        v.push_back(eng);\n        v.push_back(id * -1);\n        if (((com*5) + (math*3) + (eng*2)) % 10 == 0)\n        {\n            string str = to_string(tmp), newstr = &quot;&quot;;\n            for (int j = 0; j&lt;str.length(); j++)\n            {\n                if (str[j] == &#39;.&#39;) break;\n                newstr += str[j];\n            }\n            MAP[v] = newstr;\n        }\n        else\n        {\n            string str = to_string(tmp), newstr = &quot;&quot;;\n            for (int j = 0; j&lt;str.length(); j++)\n            {\n                newstr += str[j];\n                if (str[j] == &#39;.&#39;)\n                {\n                    newstr += str[j+1];\n                    break;\n                }\n            }\n            MAP[v] = newstr;\n        }\n        stu.push_back(v);\n    }\n    sort(stu.begin(), stu.end());\n    for (int i = N-1; i&gt;=0; i--)\n    {\n        cout &lt;&lt; stu[i][4] * -1 &lt;&lt; &quot; &quot; &lt;&lt; MAP[stu[i]] &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge H075\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u96fb\u5b50\u8a08\u7b97\u6a5f\u7814\u7a76\u793e\u8981\u4f86\u793e\u8003\u4e86\u5594:D\uff0c\u7e3d\u5171\u8981\u8003 3 \u79d1\uff0c\u5206\u5225\u662f\u8cc7\u8a0a\u3001\u6578\u5b78\u3001\u82f1\u6587\uff0c\u6bcf\u5230\u9019\u500b\u8003\u8a66\u7684\u5b63\u7bc0\uff0c\u793e\u5718\u5167\u7e3d\u662f\u6703\u5145 [&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,20,11,19,7,9],"class_list":["post-481","post","type-post","status-publish","format-standard","hentry","category-6","tag-map","tag-20","tag-11","tag-19","tag-7","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=481"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/481\/revisions"}],"predecessor-version":[{"id":483,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/481\/revisions\/483"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}