{"id":2664,"date":"2023-04-28T20:57:09","date_gmt":"2023-04-28T12:57:09","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=2664"},"modified":"2023-04-29T14:14:15","modified_gmt":"2023-04-29T06:14:15","slug":"atcoder-regular-contest-158","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/atcoder-regular-contest-158\/","title":{"rendered":"AtCoder Regular Contest 158"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/614019740\">https:\/\/zhuanlan.zhihu.com\/p\/614019740<\/a><\/li>\n<\/ul>\n<h1>Problem C. All Pair Digit Sums<\/h1>\n<p>\u548c <a href=\"https:\/\/www.shuizilong.com\/house\/archives\/atcoder-regular-contest-159\/\">#159 \u7684\u6700\u540e\u90a3\u4e2a\u9898<\/a> \u4e00\u6837\uff0c\u6211\u4eec\u4e5f\u9700\u8981\u8003\u8651\u5bb9\u65a5\uff0c\u8ba1\u7b97\u8fdb\u4f4d\u6240\u5e26\u6765\u7684\u4ee3\u4ef7\u3002<br \/>\n\u6ce8\u610f\u679a\u4e3e\u6bcf\u4e00\u4f4d\u7684\u65f6\u5019\uff0c\u8fdb\u4f4d\u53ef\u80fd\u4f1a\u4ea7\u751f\u590d\u6742\u7684\u540e\u6548\u6027\uff08\u8fdb\u4f4d\u518d\u8fdb\u4f4d&#8230;\uff09\u6211\u4eec\u4e0d\u80fd\u4ec5\u4ec5\u8003\u5bdf\u90a3\u4e00\u4f4d\u3002\u3002\u3002<br \/>\n\u800c\u662f\u9700\u8981\u6574\u4e2a\u540e\u7f00\u90fd\u7eb3\u5165\u8003\u8651\uff0c\u6bd4\u5982\u5bf9\u4e8e\u4e00\u4e2a\u672b\u5c3e\u662f 17 \u7684\u6570\u90a3\u4e48\u7b26\u5408\u6761\u4ef6\u7684\u5c31\u662f\u672b\u5c3e >= 83 \u7684\u6570\u3002\u3002\u3002<br \/>\n\u53ef\u4ee5\u6392\u5e8f\u540e\u4e8c\u5206\u67e5\u627e\u6216\u8005\u7ebf\u6027\u505a\uff0c\u590d\u6742\u5ea6 O(nlognlog(Ai))\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n#include &lt;lastweapon\/io&gt;\r\n#include &lt;lastweapon\/number&gt;\r\nusing namespace lastweapon;\r\nconst int N = int(2e5) + 9;\r\nLL a&#x5B;N], b&#x5B;N];\r\nint n;\r\n\r\nint f(LL x) {\r\n    int z = 0; while (x) {\r\n        z += x % 10;\r\n        x \/= 10;\r\n    }\r\n    return z;\r\n}\r\n\r\nint main() {\r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n#endif\r\n    LL z = 0, c = 0;\r\n    RD(n); REP(i, n) z += f(RD(a&#x5B;i])); z &lt;&lt;= 1; z *= n;\r\n    LL p10 = 1;\r\n    REP(h, 15) {\r\n        p10 *= 10; REP(i, n) b&#x5B;i] = a&#x5B;i] % p10; sort(b, b+n);\r\n        REP(i, n) c += b+n-lower_bound(b, b+n, p10-b&#x5B;i]);\r\n    }\r\n    cout &lt;&lt; z - c*9 &lt;&lt; endl;\r\n}\r\n<\/pre>\n<h1>Problem E. All Pair Shortest Paths<\/h1>\n<p>\u975e\u5e38\u5389\u5bb3\u7684\u9898\uff0c\u4e4b\u524d fhc \u51fa\u8fc7\u4e09\u5217\u7684\uff0c\u8fd9\u4e2a\u9898\u867d\u7136\u53ea\u6709\u4e24\u5217\uff0c\u4f46\u662f\u8003\u5bdf\u7684\u4e1c\u897f\u66f4\u6709\u8da3\u4e86\u3002<\/p>\n<p>General \u7684 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Floyd%E2%80%93Warshall_algorithm\">Floyd<\/a> \u662f O(n3) \u7684\uff0c\u683c\u70b9\u56fe\u4e14\u6ca1\u6709\u8d1f\u6570\u7684\u60c5\u51b5\u4e0d\u5b58\u5728\u5411\u53f3\u53c8\u6298\u8fd4\u7684\u60c5\u51b5\uff0c\u590d\u6742\u6027\u5927\u4e3a\u964d\u4f4e\uff0c\u4f46\u662f\u72b6\u6001\u4f9d\u7136\u662f O(n2) \u7684\u3002<br \/>\n\u4e0d\u8fc7\u6211\u4eec\u5927\u91cf\u8f6c\u79fb\u53ef\u4ee5\u5408\u5e76\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8003\u5bdf\u76f8\u90bb\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u5206\u7c7b\u8ba8\u8bba\u540e\u628a min \u6d88\u6389\uff0c\u5b9e\u9645\u53ea\u6709\u4e09\u79cd\u60c5\u51b5\uff0c\u4e14\u53ea\u548c\u4e4b\u524d dp \u72b6\u6001\u7684\u5dee\u6709\u5173\u3001<br \/>\n\uff08\u8fd9\u4e2a\u5341\u5206 make sense\uff0c\u56e0\u4e3a\u5176\u5b9e\u4e5f\u53ea\u6709\u4e0a\u4e0b\uff0c\u4e0b\u4e0a\uff0c\u548c\u5e73\u63a8\u3002\u4ea4\u53c9\u7684\u60c5\u51b5\u80af\u5b9a\u4e0d\u5b58\u5728\u3002\u5c31\u50cf\u6b27\u51e0\u91cc\u5f97\u5e73\u9762\u91cc\u70b9\u7684\u5339\u914d\u4e00\u6837\u56e7\uff09<\/p>\n<p>\u4e8e\u662f\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u6839\u636e\u8fd9\u4e2a\u5dee\u5408\u5e76\u540c\u7c7b\u9879\uff01\u3002\u3002\u3002\u7136\u540e\u60ca\u559c\u7684\u53d1\u73b0\u8fd9\u4e2a\u9898\u6700\u5173\u952e\u7684\u6027\u8d28\u3002\u3002\u3002<br \/>\n\u5bf9\u4e8e\u5e73\u63a8\u7684\u60c5\u51b5\u3002\u3002\u8fd9\u4e9b\u540c\u7c7b\u9879\u7684\u5dee\u4f9d\u7136\u662f\u4e0d\u53d8\u7684\uff01\uff08\u5bfb\u627e\u4e0d\u53d8\u91cf\uff01\uff09<br \/>\n\u800c\u5bf9\u4e8e\u53e6\u5916\u4e24\u79cd\u60c5\u51b5\uff0c\u65b0\u7684\u72b6\u6001\u91cc\u5b83\u4eec\u53c8\u90fd\u88ab\u5408\u5e76\u5230\u4e00\u8d77\u4e86\uff01\u3002\u3002\u3002<\/p>\n<p>\u4e8e\u662f\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u8bb0\u5f55\u4e00\u4e2a offset \u8fdb\u884c\u6574\u4f53\u8f6c\u79fb\u4e86\u3002\u3002\u540e\u9762\u5c31\u53ef\u4ee5\u5e73\u63a8\u4e86\u3002\u3002\u751a\u81f3\u5e73\u8861\u6811\u90fd\u4e0d\u9700\u8981\u3002\u3002deque \u5373\u53ef\u3002\u3002<br \/>\n\u53cd\u800c\u6700\u540e\u8fd9\u6b65\u501f\u52a9 offset \u7b80\u5316\u6570\u636e\u7ed3\u6784\u8f6c\u79fb\u7684\u9898\u5012\u662f\u975e\u5e38\u5e38\u89c1\u7684\uff0c\u751a\u81f3\u6bd4\u7ebf\u6bb5\u6811\u7684\u61d2\u6807\u8bb0\u8fd8\u8981\u7b80\u5355\uff08\u6bd4\u5982 COT6 \u91cc\u6211\u4eec\u5c31\u7528\u8fc7\uff09\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/zhuanlan.zhihu.com\/p\/614019740 Problem C. All Pair Digit Sums \u548c #159 \u7684\u6700\u540e\u90a3\u4e2a\u9898 \u4e00\u6837\uff0c\u6211\u4eec\u4e5f\u9700\u8981\u8003\u8651\u5bb9\u65a5\uff0c\u8ba1\u7b97\u8fdb\u4f4d\u6240\u5e26\u6765\u7684\u4ee3\u4ef7\u3002 \u6ce8\u610f\u679a\u4e3e\u6bcf\u4e00\u4f4d\u7684\u65f6\u5019\uff0c\u8fdb\u4f4d\u53ef\u80fd\u4f1a\u4ea7\u751f\u590d\u6742\u7684\u540e\u6548\u6027\uff08\u8fdb\u4f4d\u518d\u8fdb\u4f4d&#8230;\uff09\u6211\u4eec\u4e0d\u80fd\u4ec5\u4ec5\u8003\u5bdf\u90a3\u4e00\u4f4d\u3002\u3002\u3002 \u800c\u662f\u9700\u8981\u6574\u4e2a\u540e\u7f00\u90fd\u7eb3\u5165\u8003\u8651\uff0c\u6bd4\u5982\u5bf9\u4e8e\u4e00\u4e2a\u672b\u5c3e\u662f 17 \u7684\u6570\u90a3\u4e48\u7b26\u5408\u6761\u4ef6\u7684\u5c31\u662f\u672b\u5c3e >= 83 \u7684\u6570\u3002\u3002\u3002 \u53ef\u4ee5\u6392\u5e8f\u540e\u4e8c\u5206\u67e5\u627e\u6216\u8005\u7ebf\u6027\u505a\uff0c\u590d\u6742\u5ea6 O(nlognlog(Ai))\u3002 #include &lt;lastweapon\/io&gt; #include &lt;lastweapon\/number&gt; using namespace lastweapon; const int N = int(2e5) + 9; LL a&#x5B;N], b&#x5B;N]; int n; int f(LL x) { int z = 0; while (x) { z += x % 10; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-2664","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-GY","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=2664"}],"version-history":[{"count":11,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2664\/revisions"}],"predecessor-version":[{"id":2680,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2664\/revisions\/2680"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=2664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=2664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=2664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}