{"id":262,"date":"2024-04-27T10:18:24","date_gmt":"2024-04-27T02:18:24","guid":{"rendered":"https:\/\/seanxd.com\/?p=262"},"modified":"2024-04-27T10:18:26","modified_gmt":"2024-04-27T02:18:26","slug":"zerojudge-f277","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-f277\/","title":{"rendered":"ZeroJudge F277: \u563f\u563f\u60f3\u4e0d\u5230\u5427"},"content":{"rendered":"\n\n\n<p class=\"\">\u5049\u54c9\u5317\u4e00\u6a5f\u7814\uff0c109\u5b78\u5e74\u5ea6\u62db\u751f\u5927\u6210\u529f! \u5168\u6821700\u591a\u540d\u5b78\u751f\uff0c\u6709698\u540d\u4ee5\u6a5f\u7814\u70ba\u7b2c\u4e00\u5fd7\u9858\uff0c\u8eab\u70ba\u5317\u4e00\u7b2c\u4e00\u5927\u793e\uff0c\u6a5f\u7814\u7406\u6240\u7576\u7136\u5730\u6536\u4e86\u5168\u90e8\u7684\u5b78\u751f\uff0c\u4f46\u662f\u7531\u65bc\u5b78\u6821\u884c\u653f\u6548\u7387\u53ca\u54c1\u8cea\u7684\u4f4e\u843d\uff0c\u9001\u4f86\u7684\u540d\u55ae\uff0c\u5c45\u7136\u662f\u4e82\u4e03\u516b\u7cdf\u7684QQ \u9019\u8b93\u793e\u9577\u982d\u5f88\u75db\uff0c\u65bc\u662f\u5c31\u7b28\u7b28\u7684\u4eba\u5de5\u628a698\u540d\u5b78\u59b9\u7684\u8cc7\u6599 (<strong>\u59d3\u540d\u3001\u73ed\u7d1a\u3001\u5ea7\u865f\u3001\u500b\u4ecb<\/strong>)\uff0c\u6309\u7167\u73ed\u7d1a\u5ea7\u865f\u6392\u597d\u4e86\u3002\u7ad9\u5728\u4e00\u65c1\u7684\u7a0b\u5f0f\u6559\u5b78\u5be6\u5728\u662f\u770b\u4e0d\u4e0b\u53bb\uff0c\u5c31\u60f3\u8981\u5beb\u4e00\u500b\u7a0b\u5f0f\uff0c\u9020\u798f\u672a\u4f86\u7684\u5e79\u90e8\u5011\uff0c\u4f46\u662f\u5979\u4e5f\u4e00\u6a23\u7b28\uff0c\u60f3\u4e86\u597d\u4e45\u90fd\u60f3\u4e0d\u5230\u65b9\u6cd5\u3002\u8acb\u8070\u660e\u7684\u59b3\uff0c\u5e6b\u5fd9\u5beb\u4e00\u500b\u7a0b\u5f0f\uff0c<strong>\u628a\u793e\u5718\u6210\u54e1\u7684\u8cc7\u6599\u6309\u7167\u73ed\u7d1a\u6392\u5e8f\uff0c\u82e5\u662f\u73ed\u7d1a\u76f8\u540c\uff0c\u5c31\u6309\u7167\u5ea7\u865f\u6392\u5e8f<\/strong>\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>\u6bcf\u7b46\u6e2c\u8cc7\u7b2c\u4e00\u884c\u6703\u8f38\u5165 N\uff0c\u4ee3\u8868\u61c9\u5c46\u5b78\u59b9\u7684\u4eba\u6578\uff0c\u63a5\u8457\u6703\u6709 N \u884c\u8f38\u5165\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a<br><strong>\u59d3\u540d \u73ed\u7d1a \u5ea7\u865f \u500b\u4ecb<\/strong><br>\u5176\u4e2d<strong>\u300c\u59d3\u540d\u300d\u548c\u300c\u500b\u4ecb\u300d\u4e2d\u4e0d\u542b\u6709\u7a7a\u767d<\/strong>\uff0c <strong>\u300c\u73ed\u7d1a\u300d\u548c\u300c\u5ea7\u865f\u300d\u70ba\u6574\u6578<\/strong>\u3002<br>( N &lt;= 10<sup>5<\/sup>)<\/td><td>\u8acb\u8f38\u51fa<strong>\u6392\u5e8f\u904e\u5f8c\u7684\u793e\u54e1\u8cc7\u6599\u8868<\/strong>\uff0c\u5c0d\u65bc\u6bcf\u500b\u793e\u54e1\uff0c\u8f38\u51fa\u5169\u884c<br>\u7b2c\u4e00\u884c\u70ba : \u73ed\u7d1a \u5ea7\u865f \u59d3\u540d (\u4ee5\u7a7a\u767d\u9694\u958b)<br>\u7b2c\u4e8c\u884c\u70ba : \u500b\u4ecb<\/td><\/tr><tr><td>3<br>\u9673\u5e0c\u81fb  15  12  \u6211\u559c\u6b61\u5438\u8c93<br>\u912d\u5141\u81fb  14  27  \u6211\u8a0e\u53ad\u9673\u82ad\u6a02<br>\u9b4f\u5bb6\u7426  8  37  \u6211\u5176\u5be6\u662f\u767d\u5bb6\u7426<\/td><td>8  37  \u9b4f\u5bb6\u7426<br>\u6211\u5176\u5be6\u662f\u767d\u5bb6\u7426<br>14  27  \u912d\u5141\u81fb<br>\u6211\u8a0e\u53ad\u9673\u82ad\u6a02<br>15  12  \u9673\u5e0c\u81fb<br>\u6211\u559c\u6b61\u5438\u8c93<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge F277 \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=\"\">\u5c07<strong>\u300c\u73ed\u7d1a\u300d\u548c\u300c\u5ea7\u865f\u300d\u5b58\u5230\u4e00\u500b Pair&lt;int, int><\/strong> \u4e2d\uff0c\u4e26\u4e14<strong>\u5b58\u653e\u5230\u4e00\u500b \u9663\u5217\/Vector<\/strong> \u4e2d\uff0c\u7136\u5f8c\u628a<strong>\u300c\u59d3\u540d\u300d\u548c\u300c\u500b\u4ecb\u300d\u5b58\u5230\u4e00\u500b Pair&lt;string, string><\/strong> \u4e2d\u3002\u5ba3\u544a\u4e00\u500b Map&lt;pair&lt;int, int>, pair&lt;string, string>> \u7684\u8cc7\u6599\u578b\u614b\uff0c\u9019\u500b Map \u7684 <strong>Key \u503c\u5c31\u662f\u300c\u73ed\u7d1a\u300d\u548c\u300c\u5ea7\u865f\u300d\u7684 Pair<\/strong>\uff0c<strong>Value \u503c\u5c31\u662f\u300c\u59d3\u540d\u300d\u548c\u300c\u500b\u4ecb\u300d\u7684 Pair<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u5c07<strong>\u5b58\u6709 Pair&lt;int, int> \u7684 \u9663\u5217\/Vector \u9032\u884c Sort <\/strong>\u4e4b\u5f8c\uff0c\u7531\u5c0f\u5230\u5927\u5c07 <strong>\u9663\u5217\/Vector<\/strong> \u4e2d\u7684<strong>\u300c\u73ed\u7d1a\u300d\u548c\u300c\u5ea7\u865f\u300d\u4f9d\u5e8f\u8f38\u51fa<\/strong>\u3002\u540c\u6642\uff0c\u4f7f\u7528<strong>\u6bcf\u6b21\u8f38\u51fa\u7684 Pair&lt;int, int> \u7684 Map \u5c0d\u61c9\u5230\u7684 Value \u503c\u4f86\u8f38\u51fa\u300c\u59d3\u540d\u300d\u548c\u300c\u500b\u4ecb\u300d<\/strong>\u7684 Pair&lt;string, string>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=f277\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge F277: \u563f\u563f\u60f3\u4e0d\u5230\u5427<\/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;vector&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\n\npair&lt;int, int&gt; rtn(int a, int b)\n{\n    pair&lt;int, int&gt;tmp;\n    tmp.first = a;\n    tmp.second = b;\n    return tmp;\n}\n\npair&lt;string, string&gt; pp (string a, string b)\n{\n    pair&lt;string, string&gt;tmp;\n    tmp.first = a;\n    tmp.second = b;\n    return tmp;\n}\n\nint main() {\n    int N;\n    cin &gt;&gt; N;\n    vector&lt;pair&lt;int, int&gt;&gt;v;\n    map&lt;pair&lt;int, int&gt;, pair&lt;string, string&gt;&gt;MAP;\n    for (int i = 0; i&lt;N; i++)\n    {\n        string name, word;\n        int c, no;\n        cin &gt;&gt; name &gt;&gt; c &gt;&gt; no &gt;&gt; word;\n        pair&lt;int, int&gt;p = rtn(c, no);\n        v.push_back(p);\n        MAP[p] = pp(name, word);\n    }\n    sort(v.begin(), v.end());\n    for (int i = 0; i&lt;N; i++)\n    {\n        cout &lt;&lt; v[i].first &lt;&lt; &quot; &quot; &lt;&lt; v[i].second &lt;&lt; &quot; &quot; &lt;&lt; MAP[v[i]].first &lt;&lt; &quot;\\n&quot; &lt;&lt; MAP[v[i]].second &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge F277\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5049\u54c9\u5317\u4e00\u6a5f\u7814\uff0c109\u5b78\u5e74\u5ea6\u62db\u751f\u5927\u6210\u529f! \u5168\u6821700\u591a\u540d\u5b78\u751f\uff0c\u6709698\u540d\u4ee5\u6a5f\u7814\u70ba\u7b2c\u4e00\u5fd7\u9858\uff0c\u8eab\u70ba\u5317\u4e00\u7b2c\u4e00\u5927\u793e\uff0c\u6a5f\u7814 [&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,20,11,19,9],"class_list":["post-262","post","type-post","status-publish","format-standard","hentry","category-6","tag-map","tag-pair","tag-20","tag-11","tag-19","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/262","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=262"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/262\/revisions"}],"predecessor-version":[{"id":264,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/262\/revisions\/264"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}