{"id":210,"date":"2010-04-03T20:56:00","date_gmt":"2010-04-03T12:56:00","guid":{"rendered":"http:\/\/localhost\/?p=210"},"modified":"2010-04-03T20:56:00","modified_gmt":"2010-04-03T12:56:00","slug":"scoi2003_string_folding","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=210","title":{"rendered":"[SCOI2003]\u5b57\u7b26\u4e32\u6298\u53e0"},"content":{"rendered":"\n<p>[SCOI2003]\u5b57\u7b26\u4e32\u6298\u53e0 <\/p>\n<p>Time Limit:10000MS&#160; Memory Limit:165536K<br \/>Total Submit:21 Accepted:15 <br \/>Case Time Limit:1000MS<\/p>\n<p><strong>Description <\/strong><\/p>\n<p>  \u6298\u53e0\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a <br \/>1. \u4e00\u4e2a\u5b57\u7b26\u4e32\u53ef\u4ee5\u770b\u6210\u5b83\u81ea\u8eab\u7684\u6298\u53e0\u3002\u8bb0\u4f5cS &#61664; S <br \/>2. X(S)\u662fX(X&gt;1)\u4e2aS\u8fde\u63a5\u5728\u4e00\u8d77\u7684\u4e32\u7684\u6298\u53e0\u3002\u8bb0\u4f5cX(S) &#61664; SSSS\u2026S(X\u4e2aS)\u3002 <br \/>3. \u5982\u679cA &#61664; A\u2019, B&#61664;B\u2019\uff0c\u5219AB &#61664; A\u2019B\u2019 <br \/>\u4f8b\u5982\uff0c\u56e0\u4e3a3(A) = AAA, 2(B) = BB\uff0c\u6240\u4ee53(A)C2(B) &#61664;  AAACBB\uff0c\u800c2(3(A)C)2(B)&#61664;AAACAAACBB <br \/>\u7ed9\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u6c42\u5b83\u7684\u6700\u77ed\u6298\u53e0\u3002\u4f8b\u5982AAAAAAAAAABABABCCD\u7684\u6700\u77ed\u6298\u53e0\u4e3a\uff1a9(A)3(AB)CCD\u3002 <\/p>\n<p><strong>Input <\/strong><\/p>\n<p> \u4ec5\u4e00\u884c\uff0c\u5373\u5b57\u7b26\u4e32S\uff0c\u957f\u5ea6\u4fdd\u8bc1\u4e0d\u8d85\u8fc7100\u3002 <\/p>\n<p><strong>Output <\/strong><\/p>\n<p> \u4ec5\u4e00\u884c\uff0c\u5373\u6700\u77ed\u7684\u6298\u53e0\u957f\u5ea6\u3002 <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>NEERCYESYESYESNEERCYESYESYES<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>14<\/p>\n<p><strong>Hint <\/strong><\/p>\n<p> \u4e00\u4e2a\u6700\u77ed\u7684\u6298\u53e0\u4e3a\uff1a2(NEERC3(YES)) <\/p>\n<p><strong>Source<br \/>\u6655\u3002\u3002SCOI\u8fd9\u79cd\u7c7b\u578b\u7684\u9898\u76ee\u600e\u4e48\u8fd9\u4e48\u591a\u56e7\u3002\u3002\u8fd9\u9053\u9898\u5dee\u4e0d\u591a\u5427\uff0c\u4e5f\u662fDp\uff0c\u6bd4\u538b\u7f29\u8fd8\u7b80\u5355\uff0c\u5c31\u4e0d\u8bf4\u4e86\u3002\u3002<br \/>\u53e6\u5916&lt;?=\u8fd9\u4e2a\u64cd\u4f5c\u7b26\u5f88NB\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=120;<br \/>char M[maxl];<br \/>bool S[maxl][maxl]={0};<br \/>int Dp[maxl][maxl];<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 \/>int Cost(int x)<br \/>{<br \/>    if(x&lt;10) return 1;<br \/>    return 1+Cost(x\/10);<br \/>}<br \/>int dfs(int l,int r)<br \/>{<br \/>    int&amp;x=Dp[l][r];if(S[l][r]) return x;<br \/>    S[l][r]=true;int Len=r-l+1;x=Len;if(Len==1) return x;<br \/>    for(int k=l;k&lt;r;k++)x&lt;?=dfs(l,k)+dfs(k+1,r);<br \/>    for(int k=1;k&lt;Len;k++)if(Match(l,Len,k))x&lt;?=dfs(l,l+k-1)+2+Cost(Len\/k);<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)&lt;&lt;endl;<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[SCOI2003]\u5b57\u7b26\u4e32\u6298\u53e0 Time Limit:10000MS&#160; Memory Limit:165536KTotal Submit:21 Accepted:15 Case Time Limit:1000MS Description \u6298\u53e0\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a 1. \u4e00\u4e2a\u5b57\u7b26\u4e32\u53ef\u4ee5\u770b\u6210\u5b83\u81ea\u8eab\u7684\u6298\u53e0\u3002\u8bb0\u4f5cS &#61664; S 2. X(S)\u662fX(X&gt;1)\u4e2aS\u8fde\u63a5\u5728\u4e00\u8d77\u7684\u4e32\u7684\u6298\u53e0\u3002\u8bb0\u4f5cX(S) &#61664; SSSS\u2026S(X\u4e2aS)\u3002 3. \u5982\u679cA &#61664; A\u2019, B&#61664;B\u2019\uff0c\u5219AB &#61664; A\u2019B\u2019 \u4f8b\u5982\uff0c\u56e0\u4e3a3(A) = AAA, 2(B) = BB\uff0c\u6240\u4ee53(A)C2(B) &#61664; AAACBB\uff0c\u800c2(3(A)C)2(B)&#61664;AAACAAACBB \u7ed9\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u6c42\u5b83\u7684\u6700\u77ed\u6298\u53e0\u3002\u4f8b\u5982AAAAAAAAAABABABCCD\u7684\u6700\u77ed\u6298\u53e0\u4e3a\uff1a9(A)3(AB)CCD\u3002 Input \u4ec5\u4e00\u884c\uff0c\u5373\u5b57\u7b26\u4e32S\uff0c\u957f\u5ea6\u4fdd\u8bc1\u4e0d\u8d85\u8fc7100\u3002 Output \u4ec5\u4e00\u884c\uff0c\u5373\u6700\u77ed\u7684\u6298\u53e0\u957f\u5ea6\u3002 Sample Input NEERCYESYESYESNEERCYESYESYES Sample Output 14 Hint \u4e00\u4e2a\u6700\u77ed\u7684\u6298\u53e0\u4e3a\uff1a2(NEERC3(YES)) Source\u6655\u3002\u3002SCOI\u8fd9\u79cd\u7c7b\u578b\u7684\u9898\u76ee\u600e\u4e48\u8fd9\u4e48\u591a\u56e7\u3002\u3002\u8fd9\u9053\u9898\u5dee\u4e0d\u591a\u5427\uff0c\u4e5f\u662fDp\uff0c\u6bd4\u538b\u7f29\u8fd8\u7b80\u5355\uff0c\u5c31\u4e0d\u8bf4\u4e86\u3002\u3002\u53e6\u5916&lt;?=\u8fd9\u4e2a\u64cd\u4f5c\u7b26\u5f88NB\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 [&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\/210"}],"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=210"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/210\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}