{"id":612,"date":"2019-02-12T23:18:55","date_gmt":"2019-02-12T15:18:55","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=612"},"modified":"2019-02-12T23:18:55","modified_gmt":"2019-02-12T15:18:55","slug":"lp3804-%e3%80%90%e6%a8%a1%e6%9d%bf%e3%80%91%e5%90%8e%e7%bc%80%e8%87%aa%e5%8a%a8%e6%9c%ba","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2019\/02\/12\/lp3804-%e3%80%90%e6%a8%a1%e6%9d%bf%e3%80%91%e5%90%8e%e7%bc%80%e8%87%aa%e5%8a%a8%e6%9c%ba\/","title":{"rendered":"lp3804 \u3010\u6a21\u677f\u3011\u540e\u7f00\u81ea\u52a8\u673a"},"content":{"rendered":"\n<p>\u5982\u9898\u6240\u793a\uff0c\u8fd9\u662f\u4e00\u9053\u6a21\u677f\u9898\u3002<br>\n\u4e8b\u5b9e\u4e0a\uff0c\u5c3d\u7ba1\u540e\u7f00\u81ea\u52a8\u673a\u6709\u7740\u8f83\u4e3a\u5f3a\u5927\u548c\u5b8c\u6574\u7684\u529f\u80fd\uff0c\u4f46\u5b83\u7684\u5b9e\u73b0\u5374\u662f\u6bd4\u8f83\u7b80\u5355\u7684\u3002<br>\n\u6982\u62ec\u5730\u8bf4\uff0c\u540e\u7f00\u81ea\u52a8\u673a\u662f\u4e00\u79cd\u7528\u7ebf\u6027\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u548c\u5b57\u7b26\u6570\u4e0e\u5b57\u7b26\u96c6\u7684\u4e58\u79ef\u7684\u7a7a\u95f4\u590d\u6742\u5ea6\u6765\u50a8\u5b58\u4e00\u4e2a\u5b57\u7b26\u4e32\u91cc\u6bcf\u4e00\u4e2a\u524d\u7f00\u7684\u6240\u6709\u540e\u7f00\uff0c\u5e76\u4e14\u76f8\u540c\u7684\u5b57\u7b26\u4e32\u53ea\u4f1a\u88ab\u8868\u8fbe\u4e00\u6b21\u7684\u4e00\u7c7b\u81ea\u52a8\u673a\u3002<br>\n\u4e0b\u9762\u6211\u4eec\u8003\u8651\u5982\u4f55\u6784\u9020\u8fd9\u4e2a\u81ea\u52a8\u673a\u3002<br>\n\u6784\u9020\u540e\u7f00\u81ea\u52a8\u673a\u4f7f\u7528\u7684\u662f\u4e00\u79cd\u88ab\u79f0\u4e3a\u300c\u589e\u91cf\u7b97\u6cd5\u300d\u7684\u6784\u9020\u65b9\u6cd5\u3002\u8fd9\u79cd\u6784\u9020\u65b9\u6cd5\u5c06\u6240\u6709\u7684\u8282\u70b9\u4f9d\u6b21\u52a0\u5165\u81ea\u52a8\u673a\u3002<br>\n\u540e\u7f00\u81ea\u52a8\u673a\u7531\u4ee5\u4e0b\u56db\u4e2a\u90e8\u5206\u7ec4\u6210\uff1a<br>\n\u6839\u8282\u70b9\uff0c\u524d\u7f00\u8282\u70b9\uff0c\u7236\u4eb2\u8fb9\u548c\u5b57\u7b26\u8fb9\u3002<br>\n\u6839\u8282\u70b9\u4e00\u5f00\u59cb\u5c31\u5b58\u5728\uff0c\u5b83\u8c61\u5f81\u7740\u7a7a\u4e32\u3002\u800c\u6bcf\u4e00\u6b21\u52a0\u5165\u7684\u662f\u4e00\u4e2a\u524d\u7f00\u8282\u70b9\u3002<br>\n\u524d\u7f00\u8282\u70b9\u8868\u793a\u7684\u662f\u539f\u4e32\u4e2d\u7684\u67d0\u4e00\u4e2a\u524d\u7f00\u3002<br>\n\u6bcf\u4e2a\u524d\u7f00\u8282\u70b9\u90fd\u6709\u4e00\u6761\u7236\u4eb2\u8fb9\u8fde\u5411\u53e6\u4e00\u4e2a\u8282\u70b9\u3002<br>\n\u6bcf\u4e2a\u524d\u7f00\u8282\u70b9\u90fd\u6709\u6570\u6761\u5b57\u7b26\u8fb9\u8fde\u5411\u53e6\u4e00\u4e9b\u8282\u70b9\u3002<br>\n\u5bf9\u4e8e\u6bcf\u4e2a\u524d\u7f00\u8282\u70b9\uff0c\u5b83\u50a8\u5b58\u7684\u90fd\u662f\u4e00\u4e9b\u5b57\u7b26\u4e32\u3002<br>\n\u5177\u4f53\u800c\u8a00\uff0c\u662f\u8fd9\u4e2a\u70b9\u8868\u793a\u7684\u6700\u957f\u4e32\u7684\u6240\u6709\u957f\u5ea6\u4e25\u683c\u5927\u4e8e\u5b83\u7684\u7236\u4eb2\u7684\u6700\u957f\u4e32\u7684\u957f\u5ea6\u7684\u540e\u7f00\u3002\u8003\u8651\u5230\u8fd9\u4e2a\u6027\u8d28\uff0c\u6bcf\u4e2a\u70b9\u4e8b\u5b9e\u4e0a\u4e0d\u5fc5\u8bb0\u5f55\u6574\u4e2a\u5b57\u7b26\u4e32\u96c6\u5408\uff0c\u800c\u53ea\u9700\u8bb0\u5f55\u5b57\u7b26\u4e32\u7684\u6700\u957f\u957f\u5ea6\u5373\u53ef\u3002 <br>\n\u4ece\u8fd9\u4e2a\u8282\u70b9\u6cbf\u7740\u7236\u4eb2\u8fb9\u8d70\u5230\u6839\u7684\u8def\u5f84\u4e0a\u7684\u6240\u6709\u70b9\u8868\u793a\u7684\u5b57\u7b26\u4e32\u96c6\u5408\u6784\u6210\u7684\u65b0\u96c6\u5408\uff0c\u4e0d\u91cd\u590d\u4e0d\u9057\u6f0f\u5730\u8868\u793a\u4e86\u5f53\u524d\u70b9\u7684\u6240\u6709\u540e\u7f00\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u8bb0\u5f55\u4e00\u4e2a\u8282\u70b9nw\uff0c\u8868\u793a\u7684\u662f\u5f53\u524d\u63d2\u5165\u6700\u957f\u7684\u4e00\u4e2a\u524d\u7f00\u6240\u5728\u7684\u70b9\u3002 <br>\n\u5f53\u6211\u4eec\u52a0\u5165\u4e86\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26c\uff0c\u6211\u4eec\u8fdb\u884c\u5982\u4e0b\u5224\u65ad\u548c\u64cd\u4f5c\u3002<br>\n\u65b0\u5efa\u4e00\u4e2a\u70b9np\uff0c\u7136\u540e\u6cbf\u7740nw\u5230\u6839\u7684\u8def\u5f84\u5411\u4e0a\u641c\u7d22\uff0c\u5bf9\u8def\u5f84\u4e0a\u7684\u6bcf\u4e2a\u70b9\u8fdb\u884c\u5224\u65ad\uff0c\u5982\u679c\u8fd9\u4e2a\u70b9\u6ca1\u6709\u62c9\u51fa\u8fc7\u5b57\u7b26\u4e3ac\u7684\u8fb9\uff0c\u5c31\u5c06\u5b83\u8fde\u4e00\u6761\u5b57\u7b26\u4e3ac\u7684\u8fb9\u8fde\u5411\u65b0\u70b9\u3002\u5426\u5219\u8fdb\u884c\u5982\u4e0b\u7279\u6b8a\u5904\u7406\u3002 <br>\n\u5982\u679c\u6cbf\u7740nw\u5230\u6839\u7684\u6bcf\u4e00\u4e2a\u70b9\u90fd\u8fde\u5411\u4e86\u65b0\u70b9\uff0c\u5219\u8868\u793a\u65b0\u8282\u70b9\u8868\u793a\u7684\u6bcf\u4e00\u4e2a\u975e\u7a7a\u540e\u7f00\u90fd\u65e0\u6cd5\u5728\u5df2\u6709\u7684\u81ea\u52a8\u673a\u5185\u627e\u5230\uff0c\u90a3\u4e48\u5b83\u7684\u540e\u7f00\u5e8f\u5217\u9700\u8981\u4e14\u4ec5\u9700\u8981\u4e24\u4e2a\u70b9\u6765\u8868\u8fbe\uff1a\u5b83\u672c\u8eab\uff0c\u4ee5\u53ca\u8c61\u5f81\u7a7a\u5b57\u7b26\u4e32\u7684\u6839\u8282\u70b9\u3002<br>\n\u5426\u5219\uff0c\u6211\u4eec\u8003\u8651\u8fd9\u4e2a\u5df2\u7ecf\u6709\u5b57\u7b26\u4e3ac\u7684\u8fb9\u7684\u70b9\uff0c\u6211\u4eec\u4ee4\u5b83\u4e3ap\uff0c\u5b83\u901a\u8fc7c\u8fde\u5411\u7684\u70b9\u4e3aq\u3002\u5f88\u660e\u663e\u8fd9\u610f\u5473\u7740\uff0cnp\u4ee3\u8868\u7684\u540e\u7f00\u96c6\u5408\u4e0eq\u4ee3\u8868\u7684\u540e\u7f00\u96c6\u5408\u6709\u4ea4\u96c6\u3002 <br>\n\u4ecd\u7136\u662f\u5206\u7c7b\u8ba8\u8bba\u3002\u5982\u679cq\u8868\u793a\u7684\u5b57\u7b26\u4e32\u6570\u91cf\u662f1\u7684\u8bdd\uff0c\u90a3\u4e48\u5b83\u4ee3\u8868\u7684\u540e\u7f00\u96c6\u5408\u663e\u7136\u4e00\u5b9a\u662fnp\u4ee3\u8868\u7684\u540e\u7f00\u96c6\u5408\u7684\u4e00\u4e2a\u771f\u5b50\u96c6\u3002\u5e76\u4e14\u8fd9\u4e2a\u96c6\u5408\u5173\u4e8enp\u4ee3\u8868\u7684\u540e\u7f00\u96c6\u5408\u7684\u8865\u96c6\u6b63\u597d\u662fnp\u4ee3\u8868\u7684\u5b57\u7b26\u4e32\u96c6\u5408\u3002<br>\n\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u628anp\u7684\u7236\u4eb2\u8fb9\u8fde\u5411q\u3002<br>\n\u5982\u679cq\u8868\u793a\u7684\u5b57\u7b26\u4e32\u6570\u91cf\u5927\u4e8e1\uff0c\u8fd9\u5c31\u610f\u5473\u7740\u4e24\u8005\u7684\u540e\u7f00\u96c6\u5408\u542b\u6709\u4ea4\u9645\u5e76\u4e14\u4e92\u4e0d\u5305\u542b\u3002<br>\n\u4e8e\u662f\u6211\u4eec\u9700\u8981\u628aq\u8282\u70b9\u62c6\u6210q\u548cnq\u4e24\u4e2a\u8282\u70b9\uff0c\u5176\u4e2dnq\u8868\u793a\u88abnp\u5305\u542b\u7684\u5b57\u7b26\u4e32\u96c6\u5408\uff0c\u800cq\u8868\u793a\u4e0d\u88abnp\u5305\u542b\u7684\u5b57\u7b26\u4e32\u96c6\u5408\u3002<br>\n\u663e\u7136\u9700\u8981\u4fee\u6539\u5b57\u7b26\u8fb9c\u7684\u70b9\u53ea\u6709p\u5230\u6839\u7684\u8def\u5f84\u4e0a\u7684\u6240\u6709\u70b9\u3002\u56e0\u4e3a\u53ea\u6709\u8fd9\u4e9b\u70b9\u624d\u80fd\u591f\u62c9\u51fa\u88abnp\u5305\u542b\u7684\u5b57\u7b26\u4e32\u96c6\u5408\u3002<br>\n\u5f53\u7136\uff0c\u8fd9\u4e9b\u9700\u8981\u4fee\u6539c\u7684\u70b9\u4e5f\u4e00\u5b9a\u662f\u4e00\u6bb5\u8fde\u7eed\u7684\u533a\u95f4\u3002\u8fd9\u7531\u6bcf\u4e2a\u70b9\u5305\u542b\u7684\u540e\u7f00\u96c6\u5408\u4e0d\u91cd\u590d\u4e0d\u9057\u6f0f\u53ef\u4ee5\u5f97\u5230\u3002<br>\n\u800cq\u4e0enp\u7684\u7236\u4eb2\u90fd\u5e94\u8be5\u4fee\u6539\u5230\u70b9nq\uff0c\u8fd9\u4e5f\u5f88\u663e\u7136\uff0c\u56e0\u4e3a\u62c6\u70b9\u540eq\u8868\u793a\u7684\u540e\u7f00\u96c6\u5408\u5305\u542bnq\u8868\u793a\u7684\u540e\u7f00\u96c6\u5408\u3002<br>\n\u540c\u65f6\uff0c\u539f\u6765\u7684q\u70b9\u7684\u5b57\u7b26\u51fa\u8fb9\u4e5f\u90fd\u5e94\u8be5\u590d\u5236\u5230nq\u4e0a\u3002\u8fd9\u662f\u56e0\u4e3a\u4e00\u4e2a\u5b57\u7b26\u51fa\u8fb9\u8868\u793a\u7684\u662f\u76ee\u7684\u70b9\u5305\u542b\u4e86\u6240\u6709\u51fa\u53d1\u70b9\u6240\u5305\u542b\u7684\u6bcf\u4e00\u4e2a\u5b57\u7b26\u4e32\u672b\u5c3e\u6dfb\u4e0a\u5b57\u7b26\u8fb9\u4ee3\u8868\u7684\u5b57\u7b26\u6240\u6784\u6210\u7684\u96c6\u5408\u3002<br>\n\u6545\u800c\u62c6\u70b9\u524d\u7684q\u70b9\u7ed9\u5176\u4ed6\u7684\u70b9\u8d21\u732e\u7684\u4e00\u90e8\u5206\u5b57\u7b26\u4e32\u7684\u5b57\u7b26\u51fa\u8fb9\u7684\u51fa\u53d1\u70b9\u5728\u62c6\u70b9\u540e\u53d8\u6210\u4e86nq\u3002<\/p>\n\n\n\n<p>\u8fd9\u5c31\u5b8c\u6210\u4e86\u540e\u7f00\u81ea\u52a8\u673a\u7684\u6784\u5efa\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u8fd9\u4e00\u9898\uff0c\u6211\u4eec\u8003\u8651\u4e00\u4e2a\u663e\u800c\u6613\u89c1\u7684\u6027\u8d28\uff1a<br>\n\u4e00\u4e2a\u5b50\u4e32\u5728\u539f\u4e32\u4e2d\u51fa\u73b0\u7684\u6b21\u6570\uff0c\u7b49\u4ef7\u4e8e\u4ee5\u5b83\u4f5c\u4e3a\u540e\u7f00\u7684\u524d\u7f00\u4e2a\u6570\u3002<br>\n\u56e0\u6b64\uff0c\u53ea\u8981\u8ba1\u7b97\u7236\u4eb2\u8fb9\u6784\u6210\u7684\u6811\u4e0a\u7684\u5b50\u6811\u5927\u5c0f\u4e58\u4ee5\u8282\u70b9\u6700\u957f\u5b57\u7b26\u4e32\u957f\u5ea6\u7684\u6700\u503c\u5373\u53ef\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n#include&lt;cstring>\n \ninline long long Max(long long A,long long B){\n\treturn A>B?A:B;\n}\nint n;\nint l[2000005],fa[2000005],nxt[2000005][26],sz[2000005];\nint h[2000005],v[2000005],to[2000005];\nchar ch[2000005];\nint cnt,nw,et;\ninline void add(int U,int V){\n\t++et,v[et]=V,to[et]=h[U],h[U]=et;\n}\ninline void prpr(){\n\tl[0]=0,fa[0]=-1,sz[0]=0;\n\tcnt=nw=0;\n}\nint p,q,np,nq;\ninline void psh(int c){\n\tnp=++cnt,p=nw,l[np]=l[nw]+1,sz[np]=1,nw=np;\n\twhile(p>=0&amp;&amp;!nxt[p][c]){\n\t\tnxt[p][c]=np;\n\t\tp=fa[p];\n\t}\n\tif(p==-1){\n\t\tfa[np]=0;\n\t\treturn;\n\t}\n\tq=nxt[p][c];\n\tif(l[p]+1==l[q]){\n\t\tfa[np]=q;\n\t\treturn;\n\t}\n\tnq=++cnt;\n\tfor(int i=0;i&lt;26;++i){\n\t\tnxt[nq][i]=nxt[q][i];\n\t}\n\tfa[nq]=fa[q],fa[q]=fa[np]=nq,l[nq]=l[p]+1;\n\twhile(p>=0&amp;&amp;nxt[p][c]==q){\n\t\tnxt[p][c]=nq;\n\t\tp=fa[p];\n\t}\n}\nlong long ans=0;\ninline void dfs(int X){\n\tfor(int i=h[X];i;i=to[i]){\n\t\tdfs(v[i]);\n\t\tsz[X]+=sz[v[i]];\n\t}\n\tif(sz[X]>1){\n\t\tans=Max(ans,1ll*sz[X]*l[X]);\n\t}\n}\nvoid init(){\n\tstd::cin>>ch+1;\n\tn=strlen(ch+1);\n\tfor(int i=1;i&lt;=n;++i){\n\t\tpsh(ch[i]-'a');\n\t}\n\tfor(int i=1;i&lt;=cnt;++i){\n\t\tadd(fa[i],i);\n\t}\n\tdfs(0);\n\tprintf(\"%lld\",ans);\n}\n\nint main(){\n\tprpr();\n\tinit();\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u9898\u6240\u793a\uff0c\u8fd9\u662f\u4e00\u9053\u6a21\u677f\u9898\u3002 \u4e8b\u5b9e\u4e0a\uff0c\u5c3d\u7ba1\u540e\u7f00\u81ea\u52a8\u673a\u6709\u7740\u8f83\u4e3a\u5f3a\u5927\u548c\u5b8c\u6574\u7684\u529f\u80fd\uff0c\u4f46\u5b83\u7684\u5b9e\u73b0\u5374\u662f\u6bd4\u8f83\u7b80\u5355\u7684\u3002 \u6982\u62ec\u5730 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2019\/02\/12\/lp3804-%e3%80%90%e6%a8%a1%e6%9d%bf%e3%80%91%e5%90%8e%e7%bc%80%e8%87%aa%e5%8a%a8%e6%9c%ba\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp3804 \u3010\u6a21\u677f\u3011\u540e\u7f00\u81ea\u52a8\u673a\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[86,40,8,6,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/612"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=612"}],"version-history":[{"count":1,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/612\/revisions"}],"predecessor-version":[{"id":613,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/612\/revisions\/613"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=612"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}