| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
果然想复杂了。。我居然用了递归#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator