{"id":281,"date":"2024-04-27T11:51:11","date_gmt":"2024-04-27T03:51:11","guid":{"rendered":"https:\/\/seanxd.com\/?p=281"},"modified":"2024-04-27T11:51:13","modified_gmt":"2024-04-27T03:51:13","slug":"zerojudge-h083","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-h083\/","title":{"rendered":"ZeroJudge H083: Digital Divination"},"content":{"rendered":"\n\n\n<p class=\"\">\u5360\u535c\u7c64\u7b52\u6709 M \u652f\u7c64\uff0c\u6bcf\u4e00\u652f\u7c64\u70ba\u4e00\u500b\u7531\u82f1\u6587\u5c0f\u5beb\u5b57\u6bcd\u7d44\u6210\u7684\u5b57\u4e32\u3002\u5f9e\u7c64\u7b52\u5167\u62bd\u51fa\u5169\u652f\u7c64\uff0c\u82e5\u5c07\u9019\u5169\u652f\u7c64\u4e0a\u7684\u5b57\u4e32 S \u548c T \u9023\u63a5\u8d77\u4f86\u5f62\u6210\u7684\u5b57\u4e32\u53ef\u4ee5\u5c07\u8a72\u5b57\u4e32\u62c6\u6210\u5de6\u53f3\u5169\u534a\u4e26\u4e14\u5167\u5bb9\u4e00\u6a23\uff0c\u5247\u62bd\u5230\u8056\u7b4a\u4ee3\u8868\u795e\u660e\u540c\u610f\uff0c\u5426\u5247\u795e\u660e\u4e0d\u540c\u610f\u6216\u662f\u6c92\u56de\u7b54\u3002<\/p>\n\n\n\n<p class=\"\">\u4f8b\u5982\u62bd\u51fa\u7684\u5169\u652f\u7c64\u4e0a\u7684\u5b57\u4e32\u5206\u5225\u70ba piep \u548c ie\uff0c\u5247\u76f8\u9023\u63a5\u8d77\u4f86\u7684\u5b57\u4e32\u70ba piepie \u53ef\u4ee5\u62c6\u5206\u5de6\u53f3\u5169\u534a\u70ba\u76f8\u540c\u7684\u5b57\u4e32 pie \u548c pie\uff0c\u4f46\u62bd\u51fa\u7684\u5169\u652f\u7c64\u70ba foo \u548c bar \u6642\u5247\u4e0d\u6eff\u8db3\u689d\u4ef6\u3002<\/p>\n\n\n\n<p class=\"\">\u795e\u5947\u7684\u662f\uff0c\u82e5\u62bd\u5230\u7684\u5169\u652f\u7c64 S \u548c T \u70ba\u8056\u7b4a\uff0c\u5247\u4e0d\u7ba1\u662f<strong>\u5c07 T \u63a5\u5728 S \u5f8c\u9762\u6216\u662f\u9806\u5e8f\u53cd\u904e\u4f86\u63a5\u8d77\u4f86\uff0c\u90fd\u53ef\u4ee5\u662f\u8056\u7b4a<\/strong>\uff0c\u518d\u6b21\u8aaa\u660e\u4e86\u9019\u5169\u652f\u7c64\u6709\u8457\u67d0\u7a2e\u795e\u79d8\u529b\u91cf\u5728\u795d\u798f\u8457\u62bd\u5230\u7684\u5e78\u904b\u4eba\u3002<\/p>\n\n\n\n<p class=\"\"><strong>\u4f8b\u5982\uff1apiep \u548c ie \u4e0d\u7ba1\u662f\u4f7f\u7528 piepie \u6216\u662f iepiep \u90fd\u53ef\u4ee5\u62c6\u5206\u6210\u5169\u500b\u4e00\u6a23\u7684\u5b57\u4e32<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u8a62\u554f\u7c64\u7b52\u5167\u9019 M \u652f\u7c64\uff0c<strong>\u6709\u5e7e\u500b Pair \u53ef\u4ee5\u5f62\u6210\u8056\u7b4a<\/strong>\u3002<strong>\u76f8\u540c\u7684\u5169\u652f\u7c64\u7d44\u5408\u8a08\u7b97\u4e00\u6b21\u5373\u53ef<\/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>\u8f38\u5165\u4e00\u500b\u6b63\u6574\u6578 M\uff0c\u63a5\u4e0b\u4f86\u6709<br>\u7684\u5b57\u4e32\uff0c\u6bcf\u500b\u5b57\u4e32\u9577\u5ea6\u6700\u9577\u70ba 100\u3002<\/td><td>\u8f38\u51fa\u4e00\u500b\u6b63\u6574\u6578\uff0c\u4ee3\u8868\u6709\u5e7e\u500b Pair \u6eff\u8db3\u689d\u4ef6\u3002<\/td><\/tr><tr><td>3<br>a<br>aba<br>aaa<\/td><td>1<\/td><\/tr><tr><td>5<br>abyyyab<br>y<br>yy<br>yyy<br>yyyy<\/td><td>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=\"\">\u6536\u5b57\u4e32\u7684\u6642\u5019\u4f7f\u7528 <strong>Map \u6216 Set<\/strong> \u4f86\u5b58\u54ea\u4e9b\u5b57\u4e32\u51fa\u73fe\u904e\u3002\u4e4b\u5f8c\u4e00\u500b\u5b57\u4e32\u4e00\u500b\u5b57\u4e32\u5224\u65b7\uff0c\u7528 <strong>For\u8ff4\u5708<\/strong> \u5f9e 0 \u8dd1\u5230\u5b57\u4e32\u7684\u4e00\u534a +1 (\u56e0\u70ba\u8981 Substring)\uff0c\u78ba\u8a8d\u9019\u500b\u5b57\u4e32\u7684\u7b2c 0 \u500b\u5230\u7b2c i \u500b\u5b57\u5143\u662f\u5426\u7b49\u65bc\u9019\u500b\u5b57\u4e32\u7684\u6700\u5f8c i \u500b\u5b57\u5143\uff0c\u5982\u679c\u76f8\u7b49\u7684\u8a71\u5c31\u5224\u65b7\u4e2d\u9593\u7684\u5b57\u5143\u6709\u6c92\u6709\u5728\u8f38\u5165\u6642\u51fa\u73fe\u904e\uff0c\u5982\u679c\u6709\u7684\u8a71\u7b54\u6848\u5c31 +1\uff0c\u6700\u5f8c\u8f38\u51fa\u7b54\u6848\u5373\u53ef\u3002\u5982\u679c Substring \u592a\u591a\u6b21\u7684\u8a71\u53ef\u80fd\u6703 TLE \u6240\u4ee5\u9700\u8981\u512a\u5316\u4e00\u4e0b\u907f\u514d\u592a\u591a\u6b21\u7684 Substring\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=h083\" target=\"_blank\" rel=\"noopener\">ZeroJudge H083: \u6578\u4f4d\u5360\u535c<\/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;unordered_map&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    unordered_map&lt;string, int&gt;MAP;\n    string s[60000] = {};\n    for (int i = 0; i&lt;N; i++)\n    {\n        cin &gt;&gt; s[i];\n        MAP[s[i]]++;\n    }\n    int ans = 0;\n    for (int i = 0; i&lt;N; i++)\n    {\n        string str = s[i];\n        for (int j = 1; j&lt;(int(str.length())\/2)+1; j++)\n        {\n            string ascertain = str.substr(j, str.length() - j - j);\n            string initial = str.substr(0, j);\n            string terminal = str.substr(str.length()-j, str.length());\n            if (initial == terminal)\n            {\n                if (MAP[ascertain] &gt;= 1)\n                {\n                    ans++;\n                }\n            }\n        }\n    }\n    cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge H083\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5360\u535c\u7c64\u7b52\u6709 M \u652f\u7c64\uff0c\u6bcf\u4e00\u652f\u7c64\u70ba\u4e00\u500b\u7531\u82f1\u6587\u5c0f\u5beb\u5b57\u6bcd\u7d44\u6210\u7684\u5b57\u4e32\u3002\u5f9e\u7c64\u7b52\u5167\u62bd\u51fa\u5169\u652f\u7c64\uff0c\u82e5\u5c07\u9019\u5169\u652f\u7c64\u4e0a\u7684\u5b57\u4e32 S \u548c [&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,8,11,16,9],"class_list":["post-281","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-map","tag-8","tag-11","tag-tle","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/281","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=281"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"predecessor-version":[{"id":282,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/281\/revisions\/282"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}