Advertisement
Guest User

Untitled

a guest
Dec 15th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. using namespace std;
  5. string a,b,c;
  6. int mn=100000, current=0;
  7. bool r=false,f=true;
  8. int main()
  9. {
  10. freopen("in.txt","r",stdin);
  11. freopen("out.txt","w",stdout);
  12. cin>>a>>b>>c;
  13. for(int i=0;i<c.length();i++){
  14. if(c[i]==a[0]&&r) current=0;
  15. if(c[i]==a[0]&&!r) r=true;
  16. if(r) current++;
  17. if(c[i]==b[0]&&r){ r=false, f=false;
  18. if(current<mn) mn=current; current=0; }
  19. }
  20. if(f) cout<<"There's no such sequence";
  21. else cout<<mn-2;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement