fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <deque>
  4. #include <vector>
  5. #include <string>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. deque<char>d;
  11. string str1,str2;
  12. cin>>str1>>str2;
  13. for(int i=0;i<str1.size();i++)
  14. {
  15. d.push_back(str1[i]);
  16. }
  17. int min = -1;
  18. for(int i=0;i<str1.size();i++)
  19. {
  20. for(int j=0;j<str2.size();j++)
  21. {
  22.  
  23. if(d.front()==str2[j])
  24. {
  25. if(j>min)
  26. {
  27. min = j;
  28. d.pop_front();
  29. }
  30. else break;
  31.  
  32. }
  33. }
  34.  
  35. }
  36. if(d.empty()) cout<<"Yes"<<'\n';
  37. else cout<<"No"<<'\n';
  38.  
  39.  
  40. }
Success #stdin #stdout 0.01s 5408KB
stdin
sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter
stdout
Yes