{"id":934,"date":"2024-07-24T09:00:00","date_gmt":"2024-07-24T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=934"},"modified":"2024-06-17T16:46:54","modified_gmt":"2024-06-17T08:46:54","slug":"zerojudge-a583","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-a583\/","title":{"rendered":"ZeroJudge A583: \u5ea7\u4f4d\u8ddd\u96e2\u8a08\u7b97\u554f\u984c"},"content":{"rendered":"\n\n\n<p>\u6559\u5ba4\u6709 N\uff0aN \u500b\u5ea7\u4f4d\uff0c\u4f46\u5b78\u751f\u4eba\u6578\u9060\u5c11\u65bc N<sup>2<\/sup>\u3002\u7576\u5b78\u751f\u5c31\u5ea7\u5f8c\uff0c\u8001\u5e2b\u60f3\u77e5\u9053\u5ea7\u4f4d\u6700\u8fd1\u7684\u5169\u4f4d\u5b78\u751f\u4e4b\u9593\u7684\u8ddd\u96e2\u3002\u5728\u9019\u88e1\u7684\u8ddd\u96e2\uff0c\u6307\u7684\u662f\u6b50\u6c0f\u8ddd\u96e2\u3002\u5b78\u751f\u7684\u5ea7\u4f4d\u5ea7\u6a19\u5206\u5225\u662f (x, y)\u3002<\/p>\n\n\n\n<p>\u8209\u4f8b\u4f86\u8aaa\uff0c\u5047\u8a2d\u6709\u4e09\u4f4d\u5b78\u751f\u5165\u5ea7\uff0c\u5206\u5225\u70ba (1, 1)\u3001(1, 3)\u3001(2, 5)\u3002\u9019\u4e09\u9ede\u4e4b\u4e2d\u6700\u8fd1\u7684\u5169\u9ede\u5ea7\u6a19\u5206\u5225\u70ba (1, 1) \u548c (1, 3)\uff0c\u5176\u8ddd\u96e2\u70ba 2\u3002\u8acb\u5beb\u4e00\u500b\u7a0b\u5f0f\u8a08\u7b97\u51fa<strong>\u4f4d\u7f6e\u6700\u8fd1\u7684\u5169\u500b\u5b78\u751f\u4e4b\u9593\u7684\u8ddd\u96e2\u503c<\/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\"><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\u7d44\u8f38\u5165\u5169\u884c\u3002\u7b2c\u4e00\u884c\u6709\u5169\u500b\u6b63\u6574\u6578 N (5 \u2264 N \u2264 100) \u53ca M (3 \u2264 M \u2264 20)\uff0cN \u4ee3\u8868\u6559\u5ba4\u5927\u5c0f (\u5ea7\u4f4d\u6709 N\uff0aN \u500b)\uff0cM \u70ba\u5b78\u751f\u500b\u6578\u3002<br>\u7b2c\u4e8c\u884c\u6709 2\uff0aM \u500b\u6b63\u6574\u6578 x<sub>1<\/sub> y<sub>1<\/sub> x<sub>2<\/sub> y<sub>2<\/sub> \u2026 x<sub>M<\/sub> y<sub>M<\/sub>\uff0c\u4ee5\u7a7a\u767d\u5206\u958b\uff0c\u5206\u5225\u4ee3\u8868\u6bcf\u500b\u5b78\u751f\u5ea7\u4f4d\u7684 x \u548c y \u5ea7\u6a19\u3002<\/td><td>\u8acb\u8f38\u51fa\u76f8\u8ddd\u6700\u8fd1\u5169\u4f4d\u5b78\u751f\u7684\u8ddd\u96e2\uff0c\u8f38\u51fa\u81f3\u5c0f\u6578\u9ede\u4ee5\u4e0b 4 \u4f4d (\u4ee5\u56db\u6368\u4e94\u5165\u6cd5\u8a08\u7b97)\u3002<\/td><\/tr><tr><td>5 3<br>1 1 1 3 2 5<\/td><td>2.0000<\/td><\/tr><tr><td>20 6<br>7 7 8 9 12 17 5 11 13 4 3 2<\/td><td>2.2361<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u6536\u5230 x \u548c y \u6642\uff0c\u5f80\u524d\u627e\u5176\u4ed6\u7684\u5ea7\u6a19\u4e26\u4e14\u8a08\u7b97\u548c\u5176\u8ddd\u96e2\uff0c\u8a08\u7b97\u5ea7\u6a19\u6642\u53ef\u4ee5\u5148\u4e0d\u7528\u9032\u884c\u6839\u865f\u7684\u904b\u7b97\uff0c\u4f7f\u7528 int \u4f86\u5b58\u8cc7\u6599\u5373\u53ef\u3002\u8a08\u7b97\u5b8c\u4e4b\u5f8c\u5c07 x \u548c y \u4ee5 Pair \u7684\u65b9\u5f0f\u5b58\u5230\u4e00\u500b Vector \u4e2d\u3002\u5224\u65b7\u5230\u6700\u5c0f\u7684\u8ddd\u96e2\u5f8c\u5728\u4f7f\u7528 sqrt() \u5373\u53ef\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=a583\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge A583: \u5ea7\u4f4d\u8ddd\u96e2\u8a08\u7b97\u554f\u984c<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;math.h&gt;\n#include &lt;stdio.h&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N, M;\n    cin &gt;&gt; N &gt;&gt; M;\n    vector&lt;pair&lt;int, int&gt;&gt;seats;\n    int min = -1;\n    for (int i = 0; i&lt;M; i++) {\n        int x, y;\n        cin &gt;&gt; x &gt;&gt; y;\n        for (int j = 0; j&lt;i; j++) {\n            const int distance = pow(x - seats[j].first, 2) + pow(y - seats[j].second, 2);\n            if (min == -1 || distance &lt; min) min = distance;\n        }\n        pair&lt;int, int&gt;tmp;\n        tmp.first = x;\n        tmp.second = y;\n        seats.push_back(tmp);\n    }\n    const double ans = double(sqrt(min));\n    printf(&quot;%.4f\\n&quot;, ans);\n}\n\n\/\/ZeroJudge A583\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6559\u5ba4\u6709 N\uff0aN \u500b\u5ea7\u4f4d\uff0c\u4f46\u5b78\u751f\u4eba\u6578\u9060\u5c11\u65bc N2\u3002\u7576\u5b78\u751f\u5c31\u5ea7\u5f8c\uff0c\u8001\u5e2b\u60f3\u77e5\u9053\u5ea7\u4f4d\u6700\u8fd1\u7684\u5169\u4f4d\u5b78\u751f\u4e4b\u9593\u7684\u8ddd\u96e2\u3002\u5728\u9019\u88e1\u7684 [&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":[23,20,8,13,9],"class_list":["post-934","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-pair","tag-20","tag-8","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/934","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=934"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/934\/revisions"}],"predecessor-version":[{"id":936,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/934\/revisions\/936"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}