Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- #include <iomanip>
- #include <fstream>
- #include <string>
- #include <set>
- #include <deque>
- #include <queue>
- #include <map>
- #include <bitset>
- #include <random>
- #include <cassert>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- #define sqrt sqrtl
- #define endl "\n"
- #define all(a) a.begin(), a.end()
- #define pb push_back
- #define f1 first
- #define s2 second
- const ll inf = 1e9;
- long double eps = 1e-18;
- ll mod = 1e9 + 7;
- const ll MAXN = 100010;
- template <typename T>
- istream& operator >> (istream& in, vector <T>& a) {
- for (T& i : a) {
- in >> i;
- }
- return in;
- }
- template <typename T>
- ostream& operator << (ostream& out, vector <T>& a) {
- for (T& i : a) {
- out << i << ' ';
- }
- return out;
- }
- vector<map<ll, ll>>bor(1);
- vector<bool> flag(1);
- void add(string &s){
- ll cur_v = 0;
- for (ll i = 0; i < s.size(); i++){
- char level;
- if (s[i] <= 'z' && s[i] >= 'a')
- level = s[i] - 'a';
- else
- level = 26 + s[i] - 'A';
- if (bor[cur_v].find(level) == bor[cur_v].end()) {
- bor.push_back(map<ll, ll>());
- bor[cur_v][level] = bor.size() - 1;
- flag.push_back(0);
- }
- cur_v = bor[cur_v][level];
- }
- flag[cur_v] = 1;
- return;
- }
- ll find(string& s, ll left, ll right){
- ll cur_v = 0;
- for (; left < s.size() && left < right; left++){
- char level;
- if (s[left] <= 'z' && s[left] >= 'a')
- level = s[left] - 'a';
- else
- level = 26 + s[left] - 'A';
- if (bor[cur_v].find(level) != bor[cur_v].end())
- cur_v = bor[cur_v][level];
- else
- return -1;
- if (flag[cur_v] == 1)
- return left;
- }
- return -1;
- }
- void solve() {
- string text;
- ll t,c;
- getline(cin, text);
- ll n;
- cin >> n;
- for (ll i = 0; i < n; i++){
- string a;
- cin >> a;
- add(a);
- }
- cin >> t >> c;
- for (ll i = 0; i < text.size(); i++){
- if (text[i] != ' '){
- ll check = find(text, i, i + 10);
- if (check != -1 && ( text.size() - check - 2 + c ) / c > t){
- cout << "NO";
- return;
- }
- }
- }
- cout << "YES";
- }
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- ll t = 1;
- //cin >> t;
- while (t--) solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment