A dp question opened by the toilet! That's really! I suddenly figured it out! The Compilation speed is really fast!
Grasp the features of DP and construct the DP equation ~ Hey hey ~
/*ID:sevenst4LANG:C++PROG:prefix*/#include<stdio.h>#include<iostream>#define MAXN 200001using namespace std;int dp[MAXN];char item[201][12];char date[MAXN];int len,icnt;int strlen( char *a ){ int ret=0; while( a[ret]!='\0' ) ret++; return ret;}void input(){ for( int i=0;i<MAXN;i++ ) dp[i]=0; icnt=0; char a[800]; while( true ) { scanf( "%s",item[icnt] ); if( item[icnt][0]=='.' ) break; icnt++; } len=0; while( scanf("%s",a)!=EOF ) { for( int i=0;i<strlen(a);i++ ) date[len++]=a[i]; }}bool judge( int i,int j ){ for( int k=0;k<strlen(item[j]);k++ ) if( date[i+k]!=item[j][k] ) return false; return true;}int max( int a,int b ){ return a>b?a:b; }void dowork(){ for( int i=len-1;i>=0;i-- ) { for( int j=0;j<icnt;j++ ) { if( judge(i,j) ) dp[i]=max( dp[i],dp[i+strlen(item[j])]+strlen(item[j])); } }}int main(){ freopen( "prefix.in","r",stdin ); freopen( "prefix.out","w",stdout ); input(); dowork(); printf( "%d\n",dp[0] ); return 0;}
The problem is the language problem ~ Now C and C ++ are confused about what they are writing!