{"id":989,"date":"2014-10-01T16:02:30","date_gmt":"2014-10-01T08:02:30","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=989"},"modified":"2023-02-15T19:39:39","modified_gmt":"2023-02-15T11:39:39","slug":"bzoj-1010-hnoi2008%e7%8e%a9%e5%85%b7%e8%a3%85%e7%ae%b1toy","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/bzoj-1010-hnoi2008%e7%8e%a9%e5%85%b7%e8%a3%85%e7%ae%b1toy\/","title":{"rendered":"BZOJ 1010. [HNOI2008]\u73a9\u5177\u88c5\u7bb1toy"},"content":{"rendered":"<p>[mathjax]<\/p>\n<h3>Brief description: <\/h3>\n<p>\u7565\u3002\uff09<\/p>\n<h3>Analysis: <\/h3>\n<p>\u9996\u5148\u5199\u597d\u66b4\u529b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.shuizilong.com\/house\/wp-content\/ql-cache\/quicklatex.com-b65df11f16719832f3dcfcb18b53ef08_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#32;&#102;&#95;&#105;&#32;&#61;&#32;&#92;&#109;&#105;&#110;&#95;&#123;&#48;&#32;&#60;&#61;&#32;&#106;&#32;&#60;&#32;&#105;&#125;&#123;&#32;&#102;&#95;&#106;&#32;&#43;&#32;&#40;&#105;&#45;&#106;&#43;&#115;&#95;&#105;&#45;&#115;&#95;&#123;&#106;&#45;&#49;&#125;&#45;&#76;&#41;&#94;&#50;&#32;&#124;&#32;&#106;&#32;&#60;&#32;&#105;&#125;&#32;\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"383\" style=\"vertical-align: -6px;\"\/><\/p>\n<p>\u89c2\u5bdf\uff0c\u5fae\u8c03\uff0c\u5206\u79bb\u5e38\u6570\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n    REP_1(i, n) s&#x5B;i] += i; ++L;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.shuizilong.com\/house\/wp-content\/ql-cache\/quicklatex.com-f372edbae04de60e4207f3e0234fa92d_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#101;&#100;&#125;&#32;&#102;&#95;&#105;&#32;&#38;&#61;&#32;&#92;&#109;&#105;&#110;&#95;&#123;&#48;&#32;&#92;&#108;&#101;&#113;&#32;&#106;&#32;&#60;&#32;&#105;&#125;&#123;&#32;&#102;&#95;&#106;&#32;&#43;&#32;&#40;&#40;&#115;&#95;&#105;&#45;&#76;&#41;&#45;&#115;&#95;&#106;&#41;&#94;&#50;&#32;&#125;&#32;&#92;&#32;&#38;&#61;&#32;&#92;&#109;&#105;&#110;&#95;&#123;&#48;&#32;&#92;&#108;&#101;&#113;&#32;&#106;&#32;&#60;&#32;&#105;&#125;&#123;&#32;&#45;&#50;&#40;&#115;&#95;&#105;&#45;&#76;&#41;&#115;&#95;&#106;&#32;&#32;&#43;&#32;&#40;&#102;&#95;&#106;&#43;&#115;&#95;&#106;&#94;&#50;&#41;&#32;&#125;&#32;&#43;&#32;&#40;&#115;&#95;&#105;&#45;&#76;&#41;&#94;&#50;&#32;&#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#101;&#100;&#125;&#32;\" title=\"Rendered by QuickLaTeX.com\" height=\"31\" width=\"599\" style=\"vertical-align: 0px;\"\/><\/p>\n<p>\u5199\u6210\u659c\u7387\u4f18\u5316\u7684\u6807\u51c6\u5f62\u5f0f\uff0cb = kx + y<\/p>\n<p>\u8fd9\u91cc\u6709\uff1a<\/p>\n<ul>\n<li>$k = -2(s_i-L)$<\/li>\n<li>$x = s_j $<\/li>\n<li>$y = f_j + x^2 $<\/li>\n<\/ul>\n<p>\u8fd9\u91cc $x$ \u548c $k$ \u5747\u5355\u8c03\uff08\u56e0\u4e3a $s_i$ \u5355\u8c03\uff09\uff0c\u5355\u8c03\u961f\u5217\u5373\u53ef\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\/\/}\/* .................................................................................................................................. *\/\r\n\r\nconst int N = int(5e4) + 9;\r\n\r\nLL f&#x5B;N], s&#x5B;N]; int q&#x5B;N], cz, op;\r\nint n, L;\r\n\r\n#define k (-2*(s&#x5B;i]-L))\r\n#define x(i) (s&#x5B;i])\r\n#define y(i) (f&#x5B;i]+sqr(x(i)))\r\n#define eval(i) (k*x(i)+y(i))\r\n\r\nLL det(LL x1, LL y1, LL x2, LL y2){\r\n    return x1*y2 - x2*y1;\r\n}\r\n\r\nint dett(int p0, int p1, int p2){\r\n    LL t = det(x(p1)-x(p0), y(p1)-y(p0), x(p2)-x(p0), y(p2)-y(p0));\r\n    return t &lt; 0 ? -1 : t &gt; 0;\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    freopen(&quot;out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n\r\n    RD(n, L); REP_1(i, n) s&#x5B;i] = s&#x5B;i-1] + RD();\r\n    REP_1(i, n) s&#x5B;i] += i; ++L;\r\n\r\n    cz = 0, op = 0; q&#x5B;cz] = 0; REP_1(i, n){\r\n        while (cz &lt; op &amp;&amp; eval(q&#x5B;cz]) &gt;= eval(q&#x5B;cz+1])) ++cz;\r\n        f&#x5B;i] = eval(q&#x5B;cz]) + sqr(s&#x5B;i]-L);\r\n        while (cz &lt; op &amp;&amp; dett(q&#x5B;op-1], q&#x5B;op], i) &lt;= 0) --op;\r\n        q&#x5B;++op] = i;\r\n    }\r\n\r\n    OT(f&#x5B;n]);\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>[mathjax] Brief description: \u7565\u3002\uff09 Analysis: \u9996\u5148\u5199\u597d\u66b4\u529b\u3002 \u89c2\u5bdf\uff0c\u5fae\u8c03\uff0c\u5206\u79bb\u5e38\u6570\u3002 REP_1(i, n) s&#x5B;i] += i; ++L; \u5199\u6210\u659c\u7387\u4f18\u5316\u7684\u6807\u51c6\u5f62\u5f0f\uff0cb = kx + y \u8fd9\u91cc\u6709\uff1a $k = -2(s_i-L)$ $x = s_j $ $y = f_j + x^2 $ \u8fd9\u91cc $x$ \u548c $k$ \u5747\u5355\u8c03\uff08\u56e0\u4e3a $s_i$ \u5355\u8c03\uff09\uff0c\u5355\u8c03\u961f\u5217\u5373\u53ef\u3002 \/\/}\/* &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. *\/ const int N = int(5e4) + 9; LL f&#x5B;N], s&#x5B;N]; int q&#x5B;N], cz, [&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":[22],"tags":[118],"class_list":["post-989","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-118"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-fX","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/989","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=989"}],"version-history":[{"count":2,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/989\/revisions"}],"predecessor-version":[{"id":2355,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/989\/revisions\/2355"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}