[bzoj1068] Compression [interval motion regulation]

Source: Internet
Author: User

Read the Lujiaxin blog, feel good waves ah .... I'm sorry.

Brush the question when the time is not enough, each algorithm is written only one or two passes, so how can progress

Don't always complain that time is too little, you do not work hard >_<

Well, look at the problem.

N<=50 Range, Memory ... N^3

F[a][b][t] Indicates that there is no shortest answer to M a~b in this interval.

Enumerate breakpoints (very important idea), when T==1, apparently on the right side of the left are DP a bit; (think clearly)

Then, see if the left can be compressed, this sentence is very important, because if there is no m in the interval, it can only be the leftmost copy of copy, so can be guaranteed correctness;

Standard thinking good rigorous ah, feel their DP ability to learn more

Ps.submit when you see someone else doing 3110, code really very short tree sets of trees, well want to write AH ~

Monthly Exam Refueling ~\ (≧▽≦)/~

#include <cstdio>#include<algorithm>#include<cstring>Chars[ $];intf[ -][ -][2],mark[ -][ -][2];using namespacestd;BOOLSame (intAintb) {  intl=b-a+1;if(l%2==1)return 0;  for(inti=a;i<= (A+B)/2; i++)   if(s[i]!=s[i+l/2])return 0; return 1; }intdpintAintBintt) {  inttmp=b-a+1, l=b-a+1;if(tmp==1)return 1; if(Mark[a][b][t])returnf[a][b][t];mark[a][b][t]=1; if(t>0) for(inti=a;i<b;i++) Tmp=min (TMP,DP (A,i,1) +DP (i+1B1)+1);  for(inti=a;i<b;i++) Tmp=min (TMP,DP (a,i,t) +b-i); if(Same (A, b)) Tmp=min (TMP,DP (A, (a+b)/2,0)+1); F[a][b][t]=tmp;returntmp;}intMain () {scanf ("%s", s+1); intLen=strlen (s+1); printf ("%d", DP (1Len1)); }
View Code

[bzoj1068] Compression [interval motion regulation]

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.