fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define GG ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  4. bool isPossible(string x,int xx,string b,int m)
  5. {
  6. int i=0; char c=x[i];
  7. for(int j=0;j<m;j++)
  8. { if(b[j]==c)
  9. { if(i==(x.size()-1) )
  10. return 1;
  11. else
  12. {i++; c=x[i];
  13. }
  14. }
  15.  
  16. }
  17. return 0;
  18.  
  19. }
  20.  
  21.  
  22.  
  23.  
  24. int main () { GG;
  25. int t; cin>>t;
  26. while(t--) {
  27. int n,m; string a,b;
  28. cin>>n>>m>>a>>b;
  29. cout<<isPossible("1",3,b,m)<<"\n";
  30. }return 0;}
Success #stdin #stdout 0.01s 5288KB
stdin
1
5 4
10011
1110
stdout
1