ProgMe

Untitled

Jan 30th, 2021
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int k;
  6. map<char, vector<int>> in;
  7.  
  8. int32_t main() {
  9. cin >> k;
  10. string v[k];
  11. for(int i = 0; i < k; i++)
  12. cin >> v[i];
  13. string tmp;
  14. cin >> tmp;
  15. for(int idx = 0; idx < tmp.size(); idx++)
  16. in[tmp[idx]].push_back(idx);
  17. for(int i = 0; i < k; i++){
  18. bool ok = true;
  19. int it = -1;
  20. for(char now_e : v[i]){
  21. if(upper_bound(in[now_e].begin(), in[now_e].end(), it) != in[now_e].end())
  22. it = *upper_bound(in[now_e].begin(), in[now_e].end(), it);
  23. else
  24. ok = false;
  25. }
  26. cout << (ok ? "YES\n" : "NO\n");
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment