Combine String
#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<cmath>#include<queue>#include<vector>#include<map>using namespacestd;typedef unsignedLong LongLL;#defineMet (A, B) (Memset (A,b,sizeof (a)))Const intINF = 1e9+7;Const intN =2100;Const intMOD =9973;intDp[n][n];intMain () {CharS1[n], S2[n], s[n*2]; while(SCANF ("%s%s%s", s1+1, s2+1, s+1)!=EOF) { intLen1=strlen (s1+1), Len2=strlen (s2+1), I, J; intLen = strlen (s+1); ///printf ("%d%d%d\n", Len1, Len2, Len); if(len1+len2!=Len) {printf ("no\n"); Continue; } Met (DP,0); dp[0][0] =1; for(i=0; i<=len1; i++) for(j=0; j<=len2; J + +) { if(i==0&& j==0)Continue; if(S1[i]==s[i+j] && dp[i-1][J] &&!Dp[i][j]) dp[i][j]= dp[i-1][j]; if(S2[j]==s[i+j] && dp[i][j-1] &&!Dp[i][j]) dp[i][j]= dp[i][j-1]; } /** for (i=0; i<=len1; i++) for (j=0; j<=len2; J + +) {printf ("%d%c", Dp[i][j], J==le N2? ' \ n ': '); } */ if(Dp[len1][len2]) printf ("yes\n"); Elseprintf"no\n"); } return 0;}
View Code
"Bakassi Cup" Chinese college Student Program design Contest-Girls ' special session