{"id":153,"date":"2024-04-26T15:12:49","date_gmt":"2024-04-26T07:12:49","guid":{"rendered":"https:\/\/seanxd.com\/?p=153"},"modified":"2024-04-26T15:12:51","modified_gmt":"2024-04-26T07:12:51","slug":"zerojudge-m931","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-m931\/","title":{"rendered":"ZeroJudge M931: Game Cast"},"content":{"rendered":"\n\n\n<p class=\"\">\u6709 N \u500b\u89d2\u8272\uff0c<strong>\u6bcf\u500b\u89d2\u8272\u6709\u653b\u64ca\u529b\u548c\u9632\u79a6\u529b<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u89d2\u8272\u7684<strong>\u80fd\u529b\u503c\u662f\u653b\u64ca\u529b\u548c\u9632\u79a6\u529b\u7684\u5e73\u65b9\u548c<\/strong>\uff0c<strong>\u8f38\u51fa\u80fd\u529b\u503c\u7b2c\u4e8c\u5927\u7684\u653b\u64ca\u529b\u548c\u9632\u79a6\u529b\u6578\u503c<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u4fdd\u8b49\u6bcf\u500b\u89d2\u8272\u7684\u80fd\u529b\u503c\u76f8\u7570\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\u5305\u542b\u4e00\u500b\u6574\u6578 N (3 &lt;= N &lt;= 20)\uff0c\u8868\u793a\u6709\u591a\u5c11\u500b\u89d2\u8272\u3002<br>\u63a5\u4e0b\u4f86\u7684 N \u884c\uff0c\u6bcf\u884c\u5305\u542b\u5169\u500b\u6574\u6578 a<sub>i<\/sub> \u548c b<sub>i<\/sub> (1 &lt;= a<sub>i<\/sub>, b<sub>i <\/sub>&lt;= 100)\uff0c\u8868\u793a\u7b2c i \u500b\u89d2\u8272\u7684\u653b\u64ca\u529b\u548c\u9632\u79a6\u529b\u3002<\/td><td>\u8f38\u51fa\u5169\u500b\u6574\u6578\uff0c\u8868\u793a<strong>\u80fd\u529b\u503c\u7b2c\u4e8c\u5927\u7684\u89d2\u8272\u7684\u653b\u64ca\u529b\u548c\u9632\u79a6\u529b<\/strong>\u3002<\/td><\/tr><tr><td>3<br>3  1<br>5  2<br>1  4<\/td><td>1  4<\/td><\/tr><tr><td>6<br>6  6<br>1  3<br>8  6<br>5  4<br>2  8<br>7  2<\/td><td>6  6<\/td><\/tr><tr><td>5<br>34  35<br>84  32<br>39  79<br>59  89<br>59  31<\/td><td>84  32<\/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=\"\">\u53ef\u4ee5\u5c07 a \u548c b \u7684\u5e73\u65b9\u548c\u5b58\u5230\u4e00\u500b <strong>\u9663\u5217\/Vector<\/strong> \u4e2d\u4e26\u4f7f\u7528 <strong>Sort<\/strong> \u4f86\u6392\u5e8f\uff0c\u540c\u6642\uff0c\u56e0\u70ba<strong>\u4e0d\u6703\u6709\u5e73\u65b9\u548c\u76f8\u540c<\/strong>\u7684\u60c5\u6cc1\u51fa\u73fe\uff0c\u53ef\u4ee5\u5229\u7528 <strong>Map<\/strong> \u4f86\u5c07 a \u548c b \u5b58\u8d77\u4f86\uff0c<strong>Key \u503c\u5c31\u4f7f\u7528 a \u548c b \u7684\u5e73\u65b9\u548c<\/strong>\uff0cMap \u7684 <strong>Value \u53ef\u4ee5\u4f7f\u7528 Pair&lt;int, int><\/strong> \u4f86\u5c07 a \u548c b \u5b58\u5728\u4e00\u8d77\u3002\u8f38\u51fa\u7684\u6642\u5019\u9078\u64c7\u7b2c\u4e8c\u5927\u7684\u5e73\u65b9\u548c\uff0c<strong>\u8f38\u51fa\u5176\u5b58\u5728 Map \u4e2d\u7684 a \u548c b<\/strong>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=m931\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge M931: \u904a\u6232\u9078\u89d2<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-150\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;map&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;int&gt;num;\n    map&lt;int, pair&lt;int, int&gt;&gt;MAP;\n    for (int i = 0; i&lt;N; i++)\n    {\n        int a, b;\n        cin &gt;&gt; a &gt;&gt; b;\n        int tmp = (a*a) + (b*b);\n        num.push_back(tmp);\n        MAP[tmp].first = a;\n        MAP[tmp].second = b;\n    }\n    sort(num.begin(), num.end());\n    int tmp = num[num.size()-2];\n    cout &lt;&lt; MAP[tmp].first &lt;&lt; &quot; &quot; &lt;&lt; MAP[tmp].second &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge M931\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6709 N \u500b\u89d2\u8272\uff0c\u6bcf\u500b\u89d2\u8272\u6709\u653b\u64ca\u529b\u548c\u9632\u79a6\u529b\u3002 \u89d2\u8272\u7684\u80fd\u529b\u503c\u662f\u653b\u64ca\u529b\u548c\u9632\u79a6\u529b\u7684\u5e73\u65b9\u548c\uff0c\u8f38\u51fa\u80fd\u529b\u503c\u7b2c\u4e8c\u5927\u7684\u653b\u64ca\u529b\u548c\u9632 [&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":[25],"tags":[14,20,19,13,9],"class_list":["post-153","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-map","tag-20","tag-19","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/153","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=153"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"predecessor-version":[{"id":155,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/153\/revisions\/155"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}