标签:iostream upper turn stream app tac bsp imp string
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 485 Accepted Submission(s): 178
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstring> 5 #include<algorithm> 6 #include<set> 7 #include<map> 8 #include<queue> 9 #include<stack> 10 #include<vector> 11 using namespace std; 12 typedef long long ll; 13 #define PI acos(-1.0) 14 int t; 15 char a[2505],b[2505]; 16 int dp[2505][2505]; 17 int main() 18 { 19 scanf("%d",&t); 20 while(t--){ 21 scanf("%s",a+1); 22 scanf("%s",b+1); 23 memset(dp,0,sizeof(dp)); 24 int lena=strlen(a+1); 25 int lenb=strlen(b+1); 26 dp[0][0]=1; 27 for(int i=1;i<=lenb;i++){ 28 if(i==2&&b[i]==‘*‘) 29 dp[i][0]=1; 30 for(int j=1;j<=lena;j++){ 31 if(b[i]==‘.‘||b[i]==a[j]) 32 dp[i][j]=dp[i-1][j-1]; 33 else if(b[i]==‘*‘){ 34 dp[i][j]=dp[i-2][j]|dp[i-1][j]; 35 if((dp[i-1][j-1]||dp[i][j-1])&&a[j-1]==a[j]) 36 dp[i][j]=1; 37 } 38 } 39 } 40 if(dp[lenb][lena]==1) 41 printf("yes\n"); 42 else 43 printf("no\n"); 44 } 45 return 0; 46 }
标签:iostream upper turn stream app tac bsp imp string
原文地址:http://www.cnblogs.com/hsd-/p/7413822.html