题目描述
题目困难
样例
#include <iostream>
using namespace std;
int main()
{
string a,b,c;
char n;
while(cin>>n,n!=',') a+=n;
while(cin>>n,n!=',') b+=n;
while(cin>>n) c+=n;
if(a.size()<b.size() || a.size()<c.size()) puts("-1");
else
{
int l=0;
while(l+b.size()<=a.size())
{
int k=0;
while(k<b.size())
{
if(a[k+l]!=b[k]) break;
k++;
}
if(k==b.size()) break;
l++;
}
int r=a.size();
while(r>=0)
{
int k=0;
while(k<c.size())
{
if(a[k+r]!=c[k]) break;
k++;
}
if(k==c.size()) break;
r--;
}
l+=b.size()-1;
if(r>l) cout<<r-l-1<<endl;
else puts("-1");
}
return 0;
}