{"id":573,"date":"2024-06-13T09:00:00","date_gmt":"2024-06-13T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=573"},"modified":"2024-05-11T16:32:58","modified_gmt":"2024-05-11T08:32:58","slug":"zerojudge-d517","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-d517\/","title":{"rendered":"ZeroJudge D517: Copying Text V1"},"content":{"rendered":"\n\n\n<p class=\"\">\u5f9e\u6a5f\u5668\u4e2d\uff0c\u4e0d\u65b7\u5730\u51fa\u73fe 4 \u500b\u82f1\u6587\u5b57\u6bcd\u7684\u55ae\u5b57\uff0c\u73fe\u5728\u8981\u4f60\u6284\u5beb\u4e0b\u4f86\uff0c<br>\u5018\u82e5\u9019\u500b<strong>\u55ae\u5b57\u5df2\u7d93\u51fa\u73fe\u904e\uff0c\u5247\u6703\u4f7f\u7528\u7de8\u865f\u4e0a\u7684\u865f\u78bc\u76f4\u63a5\u66f8\u5beb<\/strong>\u3002<br>\u5018\u82e5\u9019\u500b<strong>\u55ae\u5b57\u6c92\u6709\u51fa\u73fe\u904e\uff0c\u5247\u6703\u8ce6\u4e88\u55ae\u5b57\u4e00\u500b\u65b0\u7684\u865f\u78bc<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u6bcf\u7d44\u65b0\u7684\u6e2c\u8cc7\uff0c\u4ee3\u8868\u4e0d\u540c\u4e8b\u4ef6\uff0c\u8acb\u52ff\u5c07\u5176\u7d0d\u5165\u65b0\u7684\u865f\u78bc<\/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>\u6bcf\u7d44\u8f38\u5165\u7684\u7b2c\u4e00\u884c<br>\u6709\u4e00\u500b\u6578\u5b57 N ( 1 \u2266 N \u2266 10<sup>5<\/sup>)<br>\u63a5\u4e0b\u4f86\u6703\u6709\u760b\u72c2\u79d1\u5b78\u5bb6\u8b1b\u51fa\u7684 N \u884c\u55ae\u5b57<br>\u6bcf\u884c\u7531\u5c0f\u5beb\u5b57\u6bcd a \u5230 z \u6240\u69cb\u6210\u7684 4 \u5b57\u55ae\u5b57<\/td><td>\u82e5\u9019\u500b\u5b57\u4e32\u4e4b\u524d\u5df2\u7d93\u51fa\u73fe\u904e\uff0c\u5247\u8f38\u51fa\u865f\u78bc\uff0c\u82e5\u6c92\u6709\u5247\u8f38\u51fa\u5b83\u5c07\u88ab\u7de8\u5beb\u7684\u865f\u78bc\u3002<\/td><\/tr><tr><td>5<br>eine<br>isis<br>zwei<br>drei<br>zwei<\/td><td>New! 1<br>New! 2<br>New! 3<br>New! 4<br>Old! 3<\/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&lt;string, int> \u4f86\u7d00\u9304\u5b57\u4e32\u662f\u5426\u6709\u51fa\u73fe\u904e\uff0c\u5982\u679c Map[\u6536\u5230\u7684\u5b57\u4e32] == 0 \u4ee3\u8868\u6c92\u6709\u51fa\u73fe\u904e\uff0c\u5ba3\u544a\u4e00\u500b count \u8b8a\u6578\u9810\u8a2d\u70ba 1 \u4e26\u628a Map[\u6536\u5230\u7684\u5b57\u4e32] \u8a2d\u70ba count \u4e26\u5c07 count++\u3002\u5982\u679c\u4e0d\u7b49\u65bc 0 \u4ee3\u8868\u5df2\u7d93\u51fa\u73fe\u904e\u5c31\u8f38\u51fa Map[\u6536\u5230\u7684\u5b57\u4e32]\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=d517\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge D517: \u00a0\u6587\u5b57\u6284\u5beb I<\/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;\n    while (cin &gt;&gt; N)\n    {\n        map&lt;string, int&gt;MAP;\n        int count = 1;\n        for (int i = 0; i&lt;N; i++)\n        {\n            string str;\n            cin &gt;&gt; str;\n            if (MAP[str] != 0)\n            {\n                cout &lt;&lt; &quot;Old! &quot; &lt;&lt; MAP[str] &lt;&lt; &quot;\\n&quot;;\n                continue;\n            }\n            MAP[str] = count;\n            count++;\n            cout &lt;&lt; &quot;New! &quot; &lt;&lt; MAP[str] &lt;&lt; &quot;\\n&quot;;\n        }\n    }\n}\n\n\/\/ZeroJudge D517\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5f9e\u6a5f\u5668\u4e2d\uff0c\u4e0d\u65b7\u5730\u51fa\u73fe 4 \u500b\u82f1\u6587\u5b57\u6bcd\u7684\u55ae\u5b57\uff0c\u73fe\u5728\u8981\u4f60\u6284\u5beb\u4e0b\u4f86\uff0c\u5018\u82e5\u9019\u500b\u55ae\u5b57\u5df2\u7d93\u51fa\u73fe\u904e\uff0c\u5247\u6703\u4f7f\u7528\u7de8\u865f\u4e0a\u7684\u865f\u78bc\u76f4\u63a5 [&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":[14,8,11,9],"class_list":["post-573","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-map","tag-8","tag-11","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/573","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=573"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/573\/revisions"}],"predecessor-version":[{"id":574,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/573\/revisions\/574"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}