首页 > ACM题库 > HDU-杭电 > hdu 2794 Match待解决[解题报告]C++
2014
02-14

hdu 2794 Match待解决[解题报告]C++

Match

问题描述 :

Given three strings, find the length of the longest string which is a substring of each of the three input strings. In this problem "substring" has the usual definition. A string X is a substring of a string Y if and only if string X can be created from string Y by deleting zero or more consecutive characters from the start of string Y, and deleting zero or more consecutive characters from the end of string Y.

输入:

The first line of the input is the number of test cases (less than 3000). For each case there is three lines each contains a string. The string only contains ‘a’-'z’ and up to 1000 characters long. There is a blank line before each test case.

输出:

The first line of the input is the number of test cases (less than 3000). For each case there is three lines each contains a string. The string only contains ‘a’-'z’ and up to 1000 characters long. There is a blank line before each test case.

样例输入:

3

aebcd
ebcaddwerd
fdsalebcser

sdafawerrsdfsdfwe
erfasdfafsd
egreetsdwere

aaaaa
aaaaa
aaaaa

样例输出:

3
2
5


  1. /*
    * =====================================================================================
    *
    * Filename: 1366.cc
    *
    * Description:
    *
    * Version: 1.0
    * Created: 2014年01月06日 14时52分14秒
    * Revision: none
    * Compiler: gcc
    *
    * Author: Wenxian Ni (Hello World~), [email protected]
    * Organization: AMS/ICT
    *
    * =====================================================================================
    */

    #include
    #include

    using namespace std;

    int main()
    {
    stack st;
    int n,i,j;
    int test;
    int a[100001];
    int b[100001];
    while(cin>>n)
    {
    for(i=1;i>a[i];
    for(i=1;i>b[i];
    //st.clear();
    while(!st.empty())
    st.pop();
    i = 1;
    j = 1;

    while(in)
    break;
    }
    while(!st.empty()&&st.top()==b[j])
    {
    st.pop();
    j++;
    }
    }
    if(st.empty())
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
    }
    return 0;
    }