{"id":209,"date":"2010-04-03T18:10:00","date_gmt":"2010-04-03T10:10:00","guid":{"rendered":"http:\/\/localhost\/?p=209"},"modified":"2010-04-03T18:10:00","modified_gmt":"2010-04-03T10:10:00","slug":"scoi2007_compression","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=209","title":{"rendered":"[SCOI2007]\u538b\u7f29"},"content":{"rendered":"\n<p>[SCOI2007]\u538b\u7f29<\/p>\n<p>Time Limit:1000MS&#160; Memory Limit:165536K<br \/>Total Submit:18 Accepted:10<\/p>\n<p><strong>Description <\/strong><\/p>\n<p> \u7ed9\u4e00\u4e2a\u7531\u5c0f\u5199\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\u6765\u538b\u7f29\u5176\u4e2d\u7684\u91cd\u590d\u4fe1\u606f\u3002\u538b\u7f29\u540e\u7684\u5b57\u7b26\u4e32\u9664\u4e86\u5c0f\u5199\u5b57\u6bcd\u5916\u8fd8\u53ef\u4ee5\uff08\u4f46\u4e0d\u5fc5\uff09\u5305\u542b\u5927\u5199\u5b57\u6bcdR\u4e0eM\uff0c\u5176\u4e2d M\u6807\u8bb0\u91cd\u590d\u4e32\u7684\u5f00\u59cb\uff0cR\u91cd\u590d\u4ece\u4e0a\u4e00\u4e2aM\uff08\u5982\u679c\u5f53\u524d\u4f4d\u7f6e\u5de6\u8fb9\u6ca1\u6709M\uff0c\u5219\u4ece\u4e32\u7684\u5f00\u59cb\u7b97\u8d77\uff09\u5f00\u59cb\u7684\u89e3\u538b\u7ed3\u679c\uff08\u79f0\u4e3a\u7f13\u51b2\u4e32\uff09\u3002  <br \/>bcdcdcdcd\u53ef\u4ee5\u538b\u7f29\u4e3abMcdRR\uff0c\u4e0b\u9762\u662f\u89e3\u538b\u7f29\u7684\u8fc7\u7a0b\uff1a  <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/61.187.179.132:8080\/JudgeOnline\/images\/1068\/1.jpg\" \/> <\/p>\n<p>\u53e6\u4e00\u4e2a\u4f8b\u5b50\u662fabcabcdabcabcdxyxyz\u53ef\u4ee5\u88ab\u538b\u7f29\u4e3aabcRdRMxyRz\u3002 <\/p>\n<p><strong>Input <\/strong><\/p>\n<p> \u8f93\u5165\u4ec5\u4e00\u884c\uff0c\u5305\u542b\u5f85\u538b\u7f29\u5b57\u7b26\u4e32\uff0c\u4ec5\u5305\u542b\u5c0f\u5199\u5b57\u6bcd\uff0c\u957f\u5ea6\u4e3an\u3002 <\/p>\n<p><strong>Output <\/strong><\/p>\n<p> \u8f93\u51fa\u4ec5\u4e00\u884c\uff0c\u5373\u538b\u7f29\u540e\u5b57\u7b26\u4e32\u7684\u6700\u77ed\u957f\u5ea6\u3002 <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>bcdcdcdcdxcdcdcdcd<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>12<\/p>\n<p><strong>Hint <\/strong><\/p>\n<p> \u5728\u7b2c\u4e00\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u89e3\u4e3aaaaRa\uff0c\u5728\u7b2c\u4e8c\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u89e3\u4e3abMcdRRxMcdRR\u3002  <br \/>\u3010\u9650\u5236\u3011  <br \/>50%\u7684\u6570\u636e\u6ee1\u8db3\uff1a1&lt;=n&lt;=20  <br \/>100%\u7684\u6570\u636e\u6ee1\u8db3\uff1a1&lt;=n&lt;=50  <br \/>100%\u7684\u6570\u636e\u6ee1\u8db3\uff1a1&lt;=n&lt;=50  <\/p>\n<p><strong>Source<br \/>\u5176\u5b9e\u662f\u86ee\u7b80\u5355\u7684\u4e00\u9053\u9898\u554a\uff0c\u5c31\u662fDp\u554a\uff0c\u4f46\u662f\u5404\u79cd\u4e1c\u897f\u592a\u7ea0\u7ed3\u4e86\u3002\u3002\u6211WA\u4e86N\u6b21\u3002\u3002\u3002<br \/><img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/79e4fa62681d4872eaf8f84c.jpg\" small=\"0\" class=\"blogimg\" \/><br \/>\u6655\u6b7b\uff0c\u72b6\u6001\u5b9a\u4e49\u5c31\u662f\uff08l,r,t\uff09\u8868\u793al\u5230r\u7684\u5b57\u4e32\uff0ct\u8868\u793a\u4e2d\u95f4\u80fd\u5426\u653eM\u3002\u3002\u5173\u952e\u5c31\u662f\u5982\u679c\u540e\u9762\u653e\u4e86R\u7684\u8bdd\u4e2d\u95f4\u5c31\u4e0d\u80fd\u653eM\u4e86\u6655\u6b7b\u3002\u3002WA\u4e86\u8fd9\u4e48\u591a\u6b21\uff0c\u4e0d\u60f3\u6d3b\u4e86\u56e7\u3002\u3002<br \/>Code\uff1a<br \/><\/strong><\/p>\n<p>#include&lt;cstdio&gt;<br \/>#include&lt;iostream&gt;<br \/>#include&lt;algorithm&gt;<br \/>#include&lt;string&gt;<br \/>#include&lt;vector&gt;<br \/>#include&lt;cstring&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>#define pb push_back<br \/>using namespace std;<br \/>const int inf=~0U&gt;&gt;1,maxl=100;<br \/>char M[maxl];<br \/>bool S[maxl][maxl][2]={0};<br \/>int Dp[maxl][maxl][2];<br \/>bool Match(int p,int Len,int s)<br \/>{<br \/>    if(Len%s)return false;<br \/>    rep(i,Len)if(M[p+i]!=M[p+i%s])return false;<br \/>    return true;<br \/>}<br \/>inline int Update(int&amp;x,int c){x=min(x,c);}<br \/>int dfs(int l,int r,bool t)<br \/>{<br \/>    int&amp;x=Dp[l][r][t];if(S[l][r][t]) return x;<br \/>    S[l][r][t]=true;int Len=r-l+1;x=Len;<br \/>    if(Len==1)return x;<br \/>    if(t)for(int k=l;k&lt;r;k++)Update(x,dfs(l,k,1)+1+dfs(k+1,r,1));<br \/>    for(int k=l;k&lt;r;k++)Update(x,dfs(l,k,t)+r-k);<br \/>    if(Len%2==0&amp;&amp;Match(l,Len,Len\/2)) Update(x,dfs(l,l+Len\/2-1,0)+1);<br \/>    return x;<br \/>}<br \/>int main()<br \/>{<br \/>    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>    cin&gt;&gt;M;<br \/>    cout&lt;&lt;dfs(0,strlen(M)-1,1)&lt;&lt;endl;<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[SCOI2007]\u538b\u7f29 Time Limit:1000MS&#160; Memory Limit:165536KTotal Submit:18 Accepted:10 Description \u7ed9\u4e00\u4e2a\u7531\u5c0f\u5199\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\u6765\u538b\u7f29\u5176\u4e2d\u7684\u91cd\u590d\u4fe1\u606f\u3002\u538b\u7f29\u540e\u7684\u5b57\u7b26\u4e32\u9664\u4e86\u5c0f\u5199\u5b57\u6bcd\u5916\u8fd8\u53ef\u4ee5\uff08\u4f46\u4e0d\u5fc5\uff09\u5305\u542b\u5927\u5199\u5b57\u6bcdR\u4e0eM\uff0c\u5176\u4e2d M\u6807\u8bb0\u91cd\u590d\u4e32\u7684\u5f00\u59cb\uff0cR\u91cd\u590d\u4ece\u4e0a\u4e00\u4e2aM\uff08\u5982\u679c\u5f53\u524d\u4f4d\u7f6e\u5de6\u8fb9\u6ca1\u6709M\uff0c\u5219\u4ece\u4e32\u7684\u5f00\u59cb\u7b97\u8d77\uff09\u5f00\u59cb\u7684\u89e3\u538b\u7ed3\u679c\uff08\u79f0\u4e3a\u7f13\u51b2\u4e32\uff09\u3002 bcdcdcdcd\u53ef\u4ee5\u538b\u7f29\u4e3abMcdRR\uff0c\u4e0b\u9762\u662f\u89e3\u538b\u7f29\u7684\u8fc7\u7a0b\uff1a \u53e6\u4e00\u4e2a\u4f8b\u5b50\u662fabcabcdabcabcdxyxyz\u53ef\u4ee5\u88ab\u538b\u7f29\u4e3aabcRdRMxyRz\u3002 Input \u8f93\u5165\u4ec5\u4e00\u884c\uff0c\u5305\u542b\u5f85\u538b\u7f29\u5b57\u7b26\u4e32\uff0c\u4ec5\u5305\u542b\u5c0f\u5199\u5b57\u6bcd\uff0c\u957f\u5ea6\u4e3an\u3002 Output \u8f93\u51fa\u4ec5\u4e00\u884c\uff0c\u5373\u538b\u7f29\u540e\u5b57\u7b26\u4e32\u7684\u6700\u77ed\u957f\u5ea6\u3002 Sample Input bcdcdcdcdxcdcdcdcd Sample Output 12 Hint \u5728\u7b2c\u4e00\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u89e3\u4e3aaaaRa\uff0c\u5728\u7b2c\u4e8c\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u89e3\u4e3abMcdRRxMcdRR\u3002 \u3010\u9650\u5236\u3011 50%\u7684\u6570\u636e\u6ee1\u8db3\uff1a1&lt;=n&lt;=20 100%\u7684\u6570\u636e\u6ee1\u8db3\uff1a1&lt;=n&lt;=50 100%\u7684\u6570\u636e\u6ee1\u8db3\uff1a1&lt;=n&lt;=50 Source\u5176\u5b9e\u662f\u86ee\u7b80\u5355\u7684\u4e00\u9053\u9898\u554a\uff0c\u5c31\u662fDp\u554a\uff0c\u4f46\u662f\u5404\u79cd\u4e1c\u897f\u592a\u7ea0\u7ed3\u4e86\u3002\u3002\u6211WA\u4e86N\u6b21\u3002\u3002\u3002\u6655\u6b7b\uff0c\u72b6\u6001\u5b9a\u4e49\u5c31\u662f\uff08l,r,t\uff09\u8868\u793al\u5230r\u7684\u5b57\u4e32\uff0ct\u8868\u793a\u4e2d\u95f4\u80fd\u5426\u653eM\u3002\u3002\u5173\u952e\u5c31\u662f\u5982\u679c\u540e\u9762\u653e\u4e86R\u7684\u8bdd\u4e2d\u95f4\u5c31\u4e0d\u80fd\u653eM\u4e86\u6655\u6b7b\u3002\u3002WA\u4e86\u8fd9\u4e48\u591a\u6b21\uff0c\u4e0d\u60f3\u6d3b\u4e86\u56e7\u3002\u3002Code\uff1a #include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;cstring&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)#define pb push_backusing namespace std;const int inf=~0U&gt;&gt;1,maxl=100;char M[maxl];bool S[maxl][maxl][2]={0};int Dp[maxl][maxl][2];bool Match(int p,int Len,int s){ if(Len%s)return false; rep(i,Len)if(M[p+i]!=M[p+i%s])return false; return true;}inline int Update(int&amp;x,int c){x=min(x,c);}int [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/209"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=209"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/209\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}