• POJ 2192


     1 #include <iostream>
     2 #include <string>
     3 #define MAXN 500
     4 using namespace std;
     5 
     6 bool dp[MAXN][MAXN];
     7 
     8 int main()
     9 {
    10     //freopen("acm.acm","r",stdin);
    11     int test;
    12     string s_1;
    13     string s_2;
    14     string s_3;
    15     int i;
    16     int j;
    17     int k;
    18     int time = 0;
    19     cin>>test;
    20     while(test --)
    21     {
    22         cout<<"Data set "<<++ time<<": ";
    23         memset(dp,false,sizeof(dp));
    24         cin>>s_1>>s_2>>s_3;
    25         dp[0][0] = true;
    26         for(i = 0; i <= s_1.length(); ++ i)
    27         {
    28             for(j = 0; j <= s_2.length(); ++ j)
    29             {
    30                 if(i-1 >= 0 && dp[i-1][j] && s_1[i-1] == s_3[i+j-1])
    31                 {
    32             //        if()
    33                     {
    34                         dp[i][j] = true;
    35                     }
    36                 }    
    37                 if(j-1 >= 0 && dp[i][j-1] && s_2[j-1] == s_3[i+j-1])
    38                 {
    39                     //if()
    40                     {
    41                         dp[i][j] = true;
    42                     }
    43                 }
    44             }
    45         }
    46         if(dp[s_1.length()][s_2.length()])
    47         {
    48             cout<<"yes"<<endl;
    49         }
    50         else
    51         {
    52             cout<<"no"<<endl;
    53         }
    54     }
    55 }

    关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

    技术网站地址: vmfor.com

  • 相关阅读:
    codeforces431C
    codeforces158C
    codeforces570C
    codeforces472C
    codeforces401C
    codeforces630C
    codeforces581C
    校内题目腐草为萤
    校内题目大美江湖
    洛谷P3370 && 字符串哈希讲解
  • 原文地址:https://www.cnblogs.com/gavinsp/p/4566697.html
Copyright © 2020-2023  润新知