{"id":721,"date":"2024-07-10T09:00:00","date_gmt":"2024-07-10T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=721"},"modified":"2024-06-05T17:56:26","modified_gmt":"2024-06-05T09:56:26","slug":"zerojudge-c635","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-c635\/","title":{"rendered":"ZeroJudge C635: \u57fa\u790e\u6392\u5e8f #1-2 (\u4f4d\u7f6e\u6392\u5e8f)"},"content":{"rendered":"\n\n\n<p class=\"\">\u6709\u82e5\u5e72\u884c\u6e2c\u8cc7\u3002<br>\u6bcf\u4e00\u884c\u6e2c\u8cc7\u6709 10 \u81f3 20 \u500b\u7528\u9017\u865f\u5206\u9694\u7684\u6578\u5b57\u3002<br>\u8acb\u300c<strong>\u5206\u5225\u5c0d\u6578\u5217\u4e2d\u5947\u6578\u4f4d\u7f6e\u53ca\u5076\u6578\u4f4d\u7f6e\u7684\u6578\u5b57\u52a0\u4ee5\u6392\u5e8f<\/strong>\u300d\uff0c\u4e26\u5c07\u7d50\u679c\u8f38\u51fa\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><strong>EOF \u8f38\u5165<\/strong>\uff0c\u6bcf\u4e00\u884c\u6e2c\u8cc7\u6709 10 \u81f3 20 \u500b\u7528\u9017\u865f\u5206\u9694\u7684\u6578\u5b57 N (1 &lt;= N &lt;= 100000)\u3002<\/td><td>\u5206\u5225\u5c0d\u6578\u5217\u4e2d\u5947\u6578\u4f4d\u7f6e\u53ca\u5076\u6578\u4f4d\u7f6e\u7684\u6578\u5b57\u52a0\u4ee5\u6392\u5e8f\uff0c\u4e26\u5c07\u7d50\u679c\u8f38\u51fa\u3002<\/td><\/tr><tr><td>4806,39740,87462,16241,69980,93315,6786<\/td><td>4806,16241,6786,39740,69980,93315,87462<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u4f7f\u7528\u5b57\u4e32\u5148\u5c07\u6574\u7b46\u8f38\u5165\u6536\u8d77\u4f86\uff0c\u518d\u4f86\u5c07\u5b57\u4e32\u5207\u5272\u6210\u6578\u5b57\uff0c\u4e26\u4f9d\u5e8f\u4f9d\u7167\u5176\u4f4d\u7f6e\u653e\u6578\u5947\u6578\u6216\u5076\u6578\u7684\u9663\u5217\u4e2d\u3002<\/p>\n\n\n\n<p class=\"\">\u5c07\u5169\u500b\u9663\u5217\u6392\u5e8f\u904e\u5f8c\uff0c\u8dd1 For\u8ff4\u5708 \u5c07\u5169\u500b\u9663\u5217\u4e2d\u7684\u8cc7\u6599\u8f2a\u6d41\u8f38\u51fa\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=c635\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge C635: \u57fa\u790e\u6392\u5e8f #1-2 (\u4f4d\u7f6e\u6392\u5e8f)<\/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;\nusing namespace std;\n\nint toint(const string& str) {\n    if (str.length() == 1) return str[0] - &#39;0&#39;;\n    return stoi(str);\n}\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    string str;\n    while (cin &gt;&gt; str) {\n        string tmp = &quot;&quot;;\n        vector&lt;int&gt;odd, even;\n        int count = 1;\n        for (int i = 0; i&lt;str.length(); i++) {\n            if (str[i] == &#39;,&#39; && !tmp.empty()) {\n                if (count % 2 == 0) even.push_back(toint(tmp));\n                else odd.push_back(toint(tmp));\n                count++;\n                tmp = &quot;&quot;;\n                continue;\n            }\n            tmp += str[i];\n        }\n        if (!tmp.empty()) {\n            if (count % 2 == 0) even.push_back(toint(tmp));\n            else odd.push_back(toint(tmp));\n        }\n        sort(odd.begin(), odd.end());\n        sort(even.begin(), even.end());\n        int o = 0, e = 0;\n        for (int i = 0; i&lt;count; i++) {\n            if (i % 2 == 0) {\n                cout &lt;&lt; odd[o];\n                o++;\n            }\n            else {\n                cout &lt;&lt; even[e];\n                e++;\n            }\n            if (i != count-1) cout &lt;&lt; &quot;,&quot;;\n        }\n        cout &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge C635\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u82e5\u5e72\u884c\u6e2c\u8cc7\u3002\u6bcf\u4e00\u884c\u6e2c\u8cc7\u6709 10 \u81f3 20 \u500b\u7528\u9017\u865f\u5206\u9694\u7684\u6578\u5b57\u3002\u8acb\u300c\u5206\u5225\u5c0d\u6578\u5217\u4e2d\u5947\u6578\u4f4d\u7f6e\u53ca\u5076\u6578\u4f4d\u7f6e\u7684\u6578\u5b57\u52a0\u4ee5\u6392 [&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":[29],"tags":[20,8,11,19,12,9],"class_list":["post-721","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-20","tag-8","tag-11","tag-19","tag-12","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/721","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=721"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/721\/revisions"}],"predecessor-version":[{"id":736,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/721\/revisions\/736"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}