Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- using namespace std;
- string a,b,c;
- int mn=100000, current=0;
- bool r=false,f=true;
- int main()
- {
- freopen("in.txt","r",stdin);
- freopen("out.txt","w",stdout);
- cin>>a>>b>>c;
- for(int i=0;i<c.length();i++){
- if(c[i]==a[0]&&r) current=0;
- if(c[i]==a[0]&&!r) r=true;
- if(r) current++;
- if(c[i]==b[0]&&r){ r=false, f=false;
- if(current<mn) mn=current; current=0; }
- }
- if(f) cout<<"There's no such sequence";
- else cout<<mn-2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement