{"id":608,"date":"2017-05-05T19:35:00","date_gmt":"2017-05-05T11:35:00","guid":{"rendered":"http:\/\/kylelv.com\/?p=608"},"modified":"2020-03-04T14:13:10","modified_gmt":"2020-03-04T06:13:10","slug":"bzoj-2084-poi2010antisymmetry-manacher","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=608","title":{"rendered":"bzoj 2084: [Poi2010]Antisymmetry &#8212; manacher"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fdef5fb8fce\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fdef5fb8fce\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.kylelv.com\/?p=608\/#2084_Poi2010Antisymmetry\" title=\"2084: [Poi2010]Antisymmetry\">2084: [Poi2010]Antisymmetry<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.kylelv.com\/?p=608\/#Description\" title=\"Description\">Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.kylelv.com\/?p=608\/#Input\" title=\"Input\">Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.kylelv.com\/?p=608\/#Output\" title=\"Output\">Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.kylelv.com\/?p=608\/#Sample_Input\" title=\"Sample Input\">Sample Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.kylelv.com\/?p=608\/#Sample_Output\" title=\"Sample Output\">Sample Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.kylelv.com\/?p=608\/#HINT\" title=\"HINT\">HINT<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"has-text-align-center wp-block-heading\"><span class=\"ez-toc-section\" id=\"2084_Poi2010Antisymmetry\"><\/span>2084: [Poi2010]Antisymmetry<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"has-text-align-center\">Time Limit:&nbsp;10 Sec&nbsp;&nbsp;Memory Limit:&nbsp;259 MB<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5bf9\u4e8e\u4e00\u4e2a01\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u5c06\u8fd9\u4e2a\u5b57\u7b26\u4e320\u548c1\u53d6\u53cd\u540e\uff0c\u518d\u5c06\u6574\u4e2a\u4e32\u53cd\u8fc7\u6765\u548c\u539f\u4e32\u4e00\u6837\uff0c\u5c31\u79f0\u4f5c\u201c\u53cd\u5bf9\u79f0\u201d\u5b57\u7b26\u4e32\u3002\u6bd4\u598200001111\u548c010101\u5c31\u662f\u53cd\u5bf9\u79f0\u7684\uff0c1001\u5c31\u4e0d\u662f\u3002<br>\u73b0\u5728\u7ed9\u51fa\u4e00\u4e2a\u957f\u5ea6\u4e3aN\u768401\u5b57\u7b26\u4e32\uff0c\u6c42\u5b83\u6709\u591a\u5c11\u4e2a\u5b50\u4e32\u662f\u53cd\u5bf9\u79f0\u7684\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u7b2c\u4e00\u884c\u4e00\u4e2a\u6b63\u6574\u6570N (N &lt;= 500,000)\u3002\u7b2c\u4e8c\u884c\u4e00\u4e2a\u957f\u5ea6\u4e3aN\u768401\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><br>\u4e00\u4e2a\u6b63\u6574\u6570\uff0c\u8868\u793a\u53cd\u5bf9\u79f0\u5b50\u4e32\u7684\u4e2a\u6570\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>8<br>11001011<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>7<\/p>\n\n\n\n<p>hint<br>7\u4e2a\u53cd\u5bf9\u79f0\u5b50\u4e32\u5206\u522b\u662f\uff1a01(\u51fa\u73b0\u4e24\u6b21), 10(\u51fa\u73b0\u4e24\u6b21), 0101, 1100\u548c001011<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;map>\n#include&lt;cmath>\n#include&lt;queue>\n#include&lt;cstdio>\n#include&lt;cstring>\n#include&lt;iostream>\n#include&lt;algorithm>\nusing namespace std;\n#define ll long long\n#define N 1000100\nint n,p&#91;N],mx,md,len;\nstring s;\nchar c&#91;N];\nll ans;\ninline bool ck(int x)\n{\n    if(c&#91;x+p&#91;x]]!=c&#91;x-p&#91;x]]) return (c&#91;x+p&#91;x]]-'0')+(c&#91;x-p&#91;x]]-'0')==1;\n    return c&#91;x+p&#91;x]]=='#';\n}\nint main()\n{\n    scanf(\"%d\",&amp;n);\n    cin>>s;\n    c&#91;0]='&amp;';\n    for(int i=0;i&lt;=n;i++)\n    {\n        c&#91;i&lt;&lt;1|1]='#';\n        c&#91;(i&lt;&lt;1)+2]=s&#91;i];\n    }\n    len=(n&lt;&lt;1)+2;\n    for(int i=1;i&lt;len;i++)\n    {\n        p&#91;i]=mx>i?min(p&#91;(md&lt;&lt;1)-i],mx-i):1;\n        for(;ck(i);p&#91;i]++);\n        if((i&amp;1)&amp;&amp;p&#91;i]+i>mx)\n        {\n            mx=p&#91;i]+i;\n            md=i;\n        }\n        if(i&amp;1) ans+=(p&#91;i]-1)>>1;\n    }\n    printf(\"%lld\\n\",ans);\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>2084: [Poi2010]Antisymmetry Time Limit:&nbsp;10 Sec&#038;nbs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[53],"class_list":["post-608","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-manacher"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=608"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/608\/revisions"}],"predecessor-version":[{"id":609,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/608\/revisions\/609"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}