{"id":292,"date":"2017-12-22T15:52:59","date_gmt":"2017-12-22T07:52:59","guid":{"rendered":"http:\/\/kylelv.com\/?p=292"},"modified":"2017-12-22T15:52:59","modified_gmt":"2017-12-22T07:52:59","slug":"bzoj-3676-apio2014%e5%9b%9e%e6%96%87%e4%b8%b2-%e5%9b%9e%e6%96%87%e8%87%aa%e5%8a%a8%e6%9c%ba","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=292","title":{"rendered":"bzoj 3676: [Apio2014]\u56de\u6587\u4e32 &#8212; \u56de\u6587\u81ea\u52a8\u673a"},"content":{"rendered":"<p><center><\/p>\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-69fdef75205d0\" 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-69fdef75205d0\"  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=292\/#3676_Apio2014%E5%9B%9E%E6%96%87%E4%B8%B2\" title=\"3676: [Apio2014]\u56de\u6587\u4e32\">3676: [Apio2014]\u56de\u6587\u4e32<\/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=292\/#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=292\/#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=292\/#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=292\/#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=292\/#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=292\/#HINT\" title=\"HINT\">HINT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/blog.kylelv.com\/?p=292\/#Source\" title=\"Source\">Source<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"3676_Apio2014%E5%9B%9E%E6%96%87%E4%B8%B2\"><\/span>3676: [Apio2014]\u56de\u6587\u4e32<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a020 Sec\u00a0\u00a0Memory Limit:\u00a0128 MB<\/span><\/center><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u8003\u8651\u4e00\u4e2a\u53ea\u5305\u542b\u5c0f\u5199\u62c9\u4e01\u5b57\u6bcd\u7684\u5b57\u7b26\u4e32s\u3002\u6211\u4eec\u5b9a\u4e49s\u7684\u4e00\u4e2a\u5b50\u4e32t\u7684\u201c\u51fa<br \/>\n\u73b0\u503c\u201d\u4e3at\u5728s\u4e2d\u7684\u51fa\u73b0\u6b21\u6570\u4e58\u4ee5t\u7684\u957f\u5ea6\u3002\u8bf7\u4f60\u6c42\u51fas\u7684\u6240\u6709\u56de\u6587\u5b50\u4e32\u4e2d\u7684\u6700<br \/>\n\u5927\u51fa\u73b0\u503c\u3002<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u8f93\u5165\u53ea\u6709\u4e00\u884c\uff0c\u4e3a\u4e00\u4e2a\u53ea\u5305\u542b\u5c0f\u5199\u5b57\u6bcd(a -z)\u7684\u975e\u7a7a\u5b57\u7b26\u4e32s\u3002<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u8f93\u51fa\u4e00\u4e2a\u6574\u6570\uff0c\u4e3a\u901d\u67e5\u56de\u6587\u5b50\u4e32\u7684\u6700\u5927\u51fa\u73b0\u503c\u3002<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">\u3010\u6837\u4f8b\u8f93\u5165l\u3011<br \/>\nabacaba<\/p>\n<p>\u3010\u6837\u4f8b\u8f93\u51652]<br \/>\nwww<\/p>\n<p><\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">\u3010\u6837\u4f8b\u8f93\u51fal\u3011<br \/>\n7<\/p>\n<p>\u3010\u6837\u4f8b\u8f93\u51fa2]<br \/>\n4<br \/>\n<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>&nbsp;<\/p>\n<p>\u4e00\u4e2a\u4e32\u662f\u56de\u6587\u7684\uff0c\u5f53\u4e14\u4ec5\u5f53\u5b83\u4ece\u5de6\u5230\u53f3\u8bfb\u548c\u4ece\u53f3\u5230\u5de6\u8bfb\u5b8c\u5168\u4e00\u6837\u3002<\/p>\n<p>\u5728\u7b2c\u4e00\u4e2a\u6837\u4f8b\u4e2d\uff0c\u56de\u6587\u5b50\u4e32\u67097\u4e2a\uff1aa\uff0cb\uff0cc\uff0caba\uff0caca\uff0cbacab\uff0cabacaba\uff0c\u5176\u4e2d\uff1a<\/p>\n<p>\u25cf a\u51fa\u73b04\u6b21\uff0c\u5176\u51fa\u73b0\u503c\u4e3a4\uff1a1\uff1a1=4<\/p>\n<p>\u25cf b\u51fa\u73b02\u6b21\uff0c\u5176\u51fa\u73b0\u503c\u4e3a2\uff1a1\uff1a1=2<\/p>\n<p>\u25cf c\u51fa\u73b01\u6b21\uff0c\u5176\u51fa\u73b0\u503c\u4e3al\uff1a1\uff1al=l<\/p>\n<p>\u25cf aba\u51fa\u73b02\u6b21\uff0c\u5176\u51fa\u73b0\u503c\u4e3a2\uff1a1\uff1a3=6<\/p>\n<p>\u25cf aca\u51fa\u73b01\u6b21\uff0c\u5176\u51fa\u73b0\u503c\u4e3a1=1\uff1a3=3<\/p>\n<p>\u25cfbacab\u51fa\u73b01\u6b21\uff0c\u5176\u51fa\u73b0\u503c\u4e3a1\uff1a1\uff1a5=5<\/p>\n<p>\u25cf abacaba\u51fa\u73b01\u6b21\uff0c\u5176\u51fa\u73b0\u503c\u4e3a1\uff1a1\uff1a7=7<\/p>\n<p>\u6545\u6700\u5927\u56de\u6587\u5b50\u4e32\u51fa\u73b0\u503c\u4e3a7\u3002<\/p>\n<p>\u3010\u6570\u636e\u89c4\u6a21\u4e0e\u8bc4\u5206\u3011<\/p>\n<p>\u6570\u636e\u6ee1\u8db31\u2264\u5b57\u7b26\u4e32\u957f\u5ea6\u2264300000\u3002<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Source\"><\/span>Source<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>emmm<\/p>\n<p>\u56de\u6587\u81ea\u52a8\u673a\u7684\u5165\u95e8\u9898<\/p>\n<p>\u5c31\u662f\u5efa\u597d\u56de\u6587\u81ea\u52a8\u673a\u540e\u7528fail\u6307\u9488\u53bb\u66f4\u65b0size\u5c31\u597d\u4e86<\/p>\n<p>\u5173\u4e8e\u56de\u6587\u81ea\u52a8\u673a\u7684\u6784\u9020\u65b9\u6cd5\u00a0<a href=\"https:\/\/chty.coding.me\/2017\/04\/30\/%E5%9B%9E%E6%96%87%E8%87%AA%E5%8A%A8%E6%9C%BA\/\" target=\"_blank\" rel=\"noopener\">https:\/\/chty.coding.me\/2017\/04\/30\/%E5%9B%9E%E6%96%87%E8%87%AA%E5%8A%A8%E6%9C%BA\/<\/a><\/p>\n<pre class=\"lang:c++ decode:true  \">#include&lt;map&gt;\r\n#include&lt;cmath&gt;\r\n#include&lt;queue&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;cstring&gt;\r\n#include&lt;iostream&gt;\r\n#include&lt;algorithm&gt;\r\nusing namespace std;\r\n#define inf 1000000007\r\n#define ll long long\r\n#define N 300010\r\ninline int rd()\r\n{\r\n\tint x=0,f=1;char ch=getchar();\r\n\twhile(ch&lt;'0'||ch&gt;'9'){if(ch=='-')f=-1;ch=getchar();}\r\n\twhile(ch&gt;='0'&amp;&amp;ch&lt;='9'){x=x*10+ch-'0';ch=getchar();}\r\n\treturn x*f;\r\n}\r\nchar s[N];\r\nint sz[N],tr[N][26],len[N],fal[N],now,cnt=1;\r\nvoid extend(int x,int pos)\r\n{\r\n\tint p=now;\r\n\twhile(s[pos-len[p]-1]!=s[pos]) p=fal[p];\r\n\tif(!tr[p][x])\r\n\t{\r\n\t\tint np=++cnt,q=fal[p];len[np]=len[p]+2;\r\n\t\twhile(s[pos-len[q]-1]!=s[pos]) q=fal[q];fal[np]=tr[q][x];\r\n\t\ttr[p][x]=np;\r\n\t}\r\n\tnow=tr[p][x];sz[now]++;\r\n}\r\nll ans;\r\nint main()\r\n{\r\n\tscanf(\"%s\",s);\r\n\tfal[0]=fal[1]=1;len[1]=-1;\r\n\tfor(int i=0;s[i];i++) extend(s[i]-'a',i);\r\n\tfor(int i=cnt;i;i--)\r\n\t{\r\n\t\tsz[fal[i]]+=sz[i];\r\n\t\tans=max(ans,(ll)sz[i]*len[i]);\r\n\t}\r\n\tprintf(\"%lld\\n\",ans);\r\n\treturn 0;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>3676: [Apio2014]\u56de\u6587\u4e32 Time Limit:\u00a020 Sec\u00a0\u00a0Memory Limit:\u00a01 [&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":[17],"class_list":["post-292","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-17"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/292","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=292"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/292\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/292\/revisions\/293"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}