Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

果然想复杂了。。我居然用了递归

Posted by STEVENCHEN123 at 2015-10-17 15:08:07 on Problem 1936
#include<iostream>
#include <sstream>
#include<string>
#include<cstdlib>
#include<cmath>
#include <queue>
#include<cstdio>
#include<cctype>
#include<stack>
#include<fstream>
#include<cassert>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<algorithm>
#include"limits.h"
using namespace std;
bool myfind(const string& s,const string& t,int p)
{
    // cout<<"myfind "<<s<<" "<<t<<endl;
    for (int i = s.size(); i >=1; --i)
    {
        long f=t.find(s.substr(0,i),p);
        if (f!=string::npos)
        {
            if (s.size()-i==0)
            {
                return true;
            }
            bool b=myfind(s.substr(i,s.size()-i),t,f+i);
            if (b)
            {
                return true;
            }
        }
    }
    return false;
}
int main()
{
    #ifndef ONLINE_JUDGE
    std::ios::sync_with_stdio(0);
    freopen("/Users/steven/Desktop/tmp.txt","r",stdin);
    clock_t a=clock();
    #endif
    string s,t;
    while(cin>>s>>t)
    {
        if (myfind(s,t,0))
        {
            cout<<"Yes\n";
        }
        else
            cout<<"No\n";
    }
    #ifndef ONLINE_JUDGE
    clock_t b=clock();
    cout<<"running time:"<<(b-a)/(double)CLOCKS_PER_SEC<<endl;
    #endif
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator