Test Instructions:Link
Method:Interval DP parsing: ZXR I'll take this one after a few days to finish the problem. Just remember what interval DP? OK, and then I do this problem with the heart of the SB-problem. This question is SB problem, this problem is SB problem, this problem is SB problem, grace important words three times. F[I][J] means I to j folds the smallest length. Transfer is a tease. Enumeration of the middle point K, one is i~k can not become the k+1~j of the circular section, then the direct addition and one is i~k can become the k+1~j cycle, you can add and or collapse, update the optimal value. I had a half-day to judge whether it would be a cyclic festival. It's too weak, rrrr!. Finally, because the number of loop section has forgotten itself and was 100 a such a data card!
Code:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace STD;Chars[ the];intf[ the][ the];intFlagvoidCheckintLintPintR) {if((r-p)% (p-l+1)!=0)return;intlenth=p-l+1; for(inti=p+1; i<=r;i++) {if(s[i]!=s[(i-l)%lenth+l])return; } flag=1;}intMain () {memset(F,0x3f,sizeof(f));scanf('%s ', s+1);intlen=strlen(s+1); for(intI=1; i<=len;i++) f[i][i]=1; for(intL=2; l<=len;l++) { for(intI=1; i+l-1<=len;i++) {intj=i+l-1; for(intk=i;k<j;k++) {f[i][j]=min (f[i][j],f[i][k]+f[k+1][J]); flag=0; Check (I,K,J);if(flag) {inttmp=f[i][k]+2;intbit= (j-k)/(k-i+1)+1; while(bit) bit/=Ten, tmp++; F[i][j]=min (F[I][J],TMP); } } } }printf("%d\n", f[1][len]); }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Bzoj 1090 [SCOI2003] string folding interval DP