{"id":2323,"date":"2023-02-14T15:03:42","date_gmt":"2023-02-14T07:03:42","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=2323"},"modified":"2023-02-14T15:53:50","modified_gmt":"2023-02-14T07:53:50","slug":"noi-2009","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/noi-2009\/","title":{"rendered":"NOI 2009"},"content":{"rendered":"<h2>\u8bd7\u4eba\u5c0f G<\/h2>\n<p>\u554a\u3002\u3002\u6211\u89c9\u5f97\u8fd9\u4e2a\u8fd8\u662f\u633a\u96be\u7684\u3002\u3002\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n#include &lt;lastweapon\/io&gt;\r\nusing namespace lastweapon;\r\n\r\nconst int N = int(1e5) + 9;\r\nlong double f&#x5B;N]; int pre&#x5B;N];\r\nchar str&#x5B;N]&#x5B;31]; int s&#x5B;N];\r\nPII Q&#x5B;N]; int cz, op;\r\nint n,l,p;\r\n\r\nlong double poww(long double x, int b) {\r\n    long double z = 1;\r\n    while (b) {\r\n        if (b&amp;1) z *= x;\r\n        x *= x; b &gt;&gt;= 1;\r\n    }\r\n    return z;\r\n}\r\n\r\n\r\nlong double calc(int a, int b) {\r\n    return f&#x5B;a] + poww(abs(s&#x5B;b]-s&#x5B;a]-l), p);\r\n}\r\n\r\nint left(int a, int b) {\r\n    int l = a, r = n+1;\r\n    while (l &lt; r) {\r\n        int m = (l + r) \/ 2;\r\n        if (calc(b, m) &lt;= calc(a, m)) {\r\n            r = m;\r\n        } else {\r\n            l = m + 1;\r\n        }\r\n    }\r\n    return l;\r\n}\r\n\r\n\r\nint main(){\r\n\r\n#ifndef ONLINE_JUDGE\r\n     freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n#endif\r\n\r\n    Rush {\r\n        RD(n,l,p);++l;\r\n        REP_1(i, n) s&#x5B;i] = s&#x5B;i-1] + strlen(RS(str&#x5B;i])) + 1;\r\n\r\n        cz = 0, op = 0; Q&#x5B;0] = {0, n+1};\r\n\r\n        REP_1(i, n) {\r\n            \/\/f&#x5B;i] = OO; REP(j, i) if (checkMin(f&#x5B;i], calc(j, i))) pre&#x5B;i] = j;\r\n\r\n            while (cz &lt; op &amp;&amp; Q&#x5B;cz+1].se &lt;= i) ++cz;\r\n            f&#x5B;i] = calc(pre&#x5B;i] = Q&#x5B;cz].fi, i);\r\n            int j = left(Q&#x5B;op].fi, i);\r\n            while (cz &lt; op &amp;&amp; j &lt;= Q&#x5B;op].se) j = left(Q&#x5B;--op].fi, i);\r\n\r\n            Q&#x5B;++op] = {i, j};\r\n        }\r\n\r\n        \/\/REP_1(i, n) cout &lt;&lt; f&#x5B;i] &lt;&lt; &quot; &quot;; cout &lt;&lt; endl;\r\n        \/\/REP_1(i, n) cout &lt;&lt; pre&#x5B;i] &lt;&lt; &quot; &quot;; cout &lt;&lt; endl;\r\n\r\n        if (f&#x5B;n] &gt; 1e18) puts(&quot;Too hard to arrange&quot;);\r\n        else {\r\n            printf(&quot;%.0Lf\\n&quot;, f&#x5B;n]);\r\n            VI I; int x = n; I.PB(x);\r\n            do I.PB(x = pre&#x5B;x]); while (x);\r\n\r\n            DWN(i, SZ(I), 1) {\r\n                FOR(j, I&#x5B;i]+1, I&#x5B;i-1]) printf(&quot;%s &quot;, str&#x5B;j]);\r\n                puts(str&#x5B;I&#x5B;i-1]]);\r\n            }\r\n        }\r\n        puts(&quot;--------------------&quot;);\r\n    }\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8bd7\u4eba\u5c0f G \u554a\u3002\u3002\u6211\u89c9\u5f97\u8fd9\u4e2a\u8fd8\u662f\u633a\u96be\u7684\u3002\u3002\u3002 #include &lt;lastweapon\/io&gt; using namespace lastweapon; const int N = int(1e5) + 9; long double f&#x5B;N]; int pre&#x5B;N]; char str&#x5B;N]&#x5B;31]; int s&#x5B;N]; PII Q&#x5B;N]; int cz, op; int n,l,p; long double poww(long double x, int b) { long double z = 1; while (b) { if (b&amp;1) z *= x; x *= x; [&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-2323","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-Bt","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2323","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=2323"}],"version-history":[{"count":2,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2323\/revisions"}],"predecessor-version":[{"id":2325,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2323\/revisions\/2325"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=2323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=2323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=2323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}