{"id":504,"date":"2024-05-24T09:00:00","date_gmt":"2024-05-24T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=504"},"modified":"2024-05-04T22:31:01","modified_gmt":"2024-05-04T14:31:01","slug":"zerojudge-m582","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-m582\/","title":{"rendered":"ZeroJudge M582: \u66f8\u623f (Study)"},"content":{"rendered":"\n\n\n<p class=\"\">\u4f60\u88ab\u56f0\u5728\u4e00\u9593\u53e4\u8001\u7684\u66f8\u623f\u7576\u4e2d\uff0c\u66f8\u684c\u4e0a\u7684\u7d19\u689d\u63d0\u793a\u4f60\u9700\u8981\u627e\u5230\u623f\u9580\u6a5f\u95dc\u7684\u8a2d\u8a08\u7a3f\u4f86\u9003\u812b\u3002\u5df2\u77e5\u66f8\u623f\u4e2d\u6709 N \u500b\u66f8\u67b6 (\u7de8\u865f\u70ba 1, 2, \u2026, N \u865f)\uff0c\u8a2d\u8a08\u7a3f\u88ab\u5206\u6210 M \u500b\u788e\u7247 (\u7de8\u865f\u70ba 1, 2, \u2026, M \u865f)\uff0c\u85cf\u5728\u67d0\u4e9b\u66f8\u67b6\u7684\u89d2\u843d\u3002\u8acb\u4f9d\u7167\u8a2d\u8a08\u7a3f\u7684\u7de8\u865f\uff0c\u8f38\u51fa\u5176\u6240\u5728\u7684\u66f8\u67b6\u7de8\u865f\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\u5217\u5305\u542b\u5169\u500b\u6b63\u6574\u6578 N (1 \u2264 N \u2264 1000) \u548c M (1 \u2264 M \u2264 N)\uff0c\u8868\u793a\u6709 N \u500b\u66f8\u67b6\uff0cM \u5f35\u8a2d\u8a08\u7a3f\u788e\u7247\u3002<br>\u7b2c\u4e8c\u5217\u8f38\u5165 N \u500b\u6578 A<sub>i<\/sub> (0 \u2264 ai \u2264 M\uff0c1 \u2264 i \u2264 N)\uff0c\u8868\u793a\u7de8\u865f i \u865f\u7684\u66f8\u67b6\u4e0a\u7684\u8a2d\u8a08\u7a3f\u7de8\u865f\uff0c\u5982\u679c\u8a72\u66f8\u67b6\u6c92\u6709\u8a2d\u8a08\u7a3f\u5247 A<sub>i<\/sub> \u70ba 0\u3002\u4e00\u500b\u66f8\u67b6\u4e0a\u6700\u591a\u53ea\u6703\u6709\u4e00\u5f35\u8a2d\u8a08\u7a3f\uff0c\u4e14\u4fdd\u8b49\u8a2d\u8a08\u7a3f\u7de8\u865f\u4e0d\u91cd\u8907\u3002<br>\u8f38\u5165\u540c\u4e00\u5217\u4e2d\u7684\u5169\u500b\u6574\u6578\u9593\u4ee5\u7a7a\u767d\u9593\u9694\u3002<\/td><td>\u8f38\u51fa M \u500b\u6b63\u6574\u6578,\u4f9d\u5e8f\u8868\u793a\u7de8\u865f 1, 2, \u2026, M \u865f\u7684\u8a2d\u8a08\u7a3f\u6240\u5728\u7684\u66f8\u67b6\u7de8\u865f\u3002<br>\u5169\u500b\u6574\u6578\u9593\u4ee5\u7a7a\u767d\u9593\u9694\u3002<\/td><\/tr><tr><td>10  3<br>0  2  1  0  0  0  0  0  3  0<\/td><td>3  2  9<\/td><\/tr><tr><td>5  5<br>4  1  2  3  5<\/td><td>2  3  4  1  5<\/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 Map \u4f86\u5b58\u8a2d\u8a08\u7a3f\u7684\u4f4d\u7f6e\uff0c\u5982\u679c A<sub>i <\/sub>\u4e0d\u662f 0 \u7684\u8a71\u5c31\u5c07 Map[A<sub>i<\/sub>] \u8a2d\u70ba i\u3002<\/p>\n\n\n\n<p class=\"\">\u8f38\u51fa\u7684\u6642\u5019\u4f7f\u7528 for (auto it:Map)\uff0c\u4e26\u8f38\u51fa it.second\uff0c\u8ff4\u5708\u6703\u81ea\u52d5\u5f9e 1 \u958b\u59cb\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u64d4\u5fc3\u6392\u5e8f\u7684\u554f\u984c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=m582\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge M582: \u66f8\u623f (Study)<\/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;\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    map&lt;int, int&gt;MAP;\n    for (int i = 0; i&lt;N; i++)\n    {\n        int tmp;\n        cin &gt;&gt; tmp;\n        if (tmp != 0) MAP[tmp] = i+1;\n    }\n    for (auto it:MAP)\n    {\n        cout &lt;&lt; it.second &lt;&lt; &quot; &quot;;\n    }\n    cout &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge M582\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u88ab\u56f0\u5728\u4e00\u9593\u53e4\u8001\u7684\u66f8\u623f\u7576\u4e2d\uff0c\u66f8\u684c\u4e0a\u7684\u7d19\u689d\u63d0\u793a\u4f60\u9700\u8981\u627e\u5230\u623f\u9580\u6a5f\u95dc\u7684\u8a2d\u8a08\u7a3f\u4f86\u9003\u812b\u3002\u5df2\u77e5\u66f8\u623f\u4e2d\u6709 N \u500b\u66f8\u67b6 (\u7de8\u865f [&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,23,8,9],"class_list":["post-504","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-map","tag-pair","tag-8","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/504","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=504"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/504\/revisions"}],"predecessor-version":[{"id":505,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/504\/revisions\/505"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}