Bzoj 1090 [SCOI2003] string folding interval DP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.