{"id":126,"date":"2024-04-26T13:27:07","date_gmt":"2024-04-26T05:27:07","guid":{"rendered":"https:\/\/seanxd.com\/?p=126"},"modified":"2024-04-26T13:27:09","modified_gmt":"2024-04-26T05:27:09","slug":"zerojudge-a915","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-a915\/","title":{"rendered":"ZeroJudge A915: 2D Point Sorting"},"content":{"rendered":"\n\n\n<p class=\"\">\u7d66\u4f60 N \u500b\u4e8c\u7dad\u5e73\u9762\u4e0a\u7684\u9ede\uff0c\u8acb\u4f60\u628a\u4ed6\u5011\u6309\u7167\u4ee5 <strong>x \u8ef8\u5ea7\u6a19<\/strong>\u70ba\u7b2c\u4e00\u500b\u95dc\u9375\u5b57\uff0c<strong>y \u8ef8\u5ea7\u6a19<\/strong>\u70ba\u7b2c\u4e8c\u95dc\u9375\u5b57\u7684\u65b9\u5f0f<strong>\u5f9e\u5c0f\u5230\u5927\u4f86\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>\u7b2c\u4e00\u884c\u8f38\u5165\u4e00\u500b\u6b63\u6574\u6578 N\u3002<br>\u63a5\u4e0b\u4f86 N \u884c\uff0c\u7b2c i \u884c\u6709\u5169\u500b\u500b\u4ee5\u7a7a\u683c\u9694\u958b\u7684\u6b63\u6574\u6578 x[i] \u548c y[i]\uff0c\u8868\u793a\u7b2c i \u500b\u9ede\u70ba(x[i], y[i])\u3002<\/td><td>\u8f38\u51fa N \u884c\uff0c\u7b2c i \u884c\u8868\u793a\u6392\u5e8f\u597d\u5f8c\u7b2c i \u500b\u9ede\u7684\u5ea7\u6a19\u3002<\/td><\/tr><tr><td>4<br>2  4<br>1  2<br>3  4<br>2  3<\/td><td>1  2<br>2  3<br>2  4<br>3  4<\/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=\"\">\u5c07\u5ea7\u6a19\u6536\u5230\u4e00\u500b <strong>Pair&lt;int, int><\/strong> \u4e2d\uff0c\u4e26\u5c07\u9019\u4e9b <strong>Pair<\/strong> \u5b58\u5230\u4e00\u500b<strong>\u9663\u5217<\/strong>\u6216<strong>Vector<\/strong>\u4e2d\u3002\u9032\u884c<strong>Sort<\/strong>\u4e4b\u5f8c\u4f7f\u7528<strong>For<\/strong>\u8ff4\u5708\u5c07\u9663\u5217\u4e2d\u7684\u8cc7\u6599\u4f9d\u5e8f\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=a915\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge A915: \u4e8c\u7dad\u9ede\u6392\u5e8f<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right\"><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 main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    cin &gt;&gt; N;\n    vector&lt;pair&lt;int, int&gt;&gt;v;\n    for (int i = 0; i&lt;N; i++)\n    {\n        int x, y;\n        cin &gt;&gt; x &gt;&gt; y;\n        pair&lt;int, int&gt; axis;\n        axis.first = x;\n        axis.second = y;\n        v.push_back(axis);\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;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge A915\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7d66\u4f60 N \u500b\u4e8c\u7dad\u5e73\u9762\u4e0a\u7684\u9ede\uff0c\u8acb\u4f60\u628a\u4ed6\u5011\u6309\u7167\u4ee5 x \u8ef8\u5ea7\u6a19\u70ba\u7b2c\u4e00\u500b\u95dc\u9375\u5b57\uff0cy \u8ef8\u5ea7\u6a19\u70ba\u7b2c\u4e8c\u95dc\u9375\u5b57\u7684\u65b9\u5f0f\u5f9e\u5c0f\u5230\u5927\u4f86 [&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":[23,20,19,9],"class_list":["post-126","post","type-post","status-publish","format-standard","hentry","category-6","tag-pair","tag-20","tag-19","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/126","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=126"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/126\/revisions"}],"predecessor-version":[{"id":127,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/126\/revisions\/127"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}