Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int k;
- map<char, vector<int>> in;
- int32_t main() {
- cin >> k;
- string v[k];
- for(int i = 0; i < k; i++)
- cin >> v[i];
- string tmp;
- cin >> tmp;
- for(int idx = 0; idx < tmp.size(); idx++)
- in[tmp[idx]].push_back(idx);
- for(int i = 0; i < k; i++){
- bool ok = true;
- int it = -1;
- for(char now_e : v[i]){
- if(upper_bound(in[now_e].begin(), in[now_e].end(), it) != in[now_e].end())
- it = *upper_bound(in[now_e].begin(), in[now_e].end(), it);
- else
- ok = false;
- }
- cout << (ok ? "YES\n" : "NO\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment