Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool check(const std::string& s, const std::vector<std::string>& d)
- {
- auto ts = s;
- while (true)
- {
- auto match = std::make_pair(ts.npos, 0);
- for (auto&& w : d)
- {
- auto pos = ts.find(w);
- if (pos != ts.npos && w.length() > match.second)
- {
- match = std::make_pair(pos, w.length());
- }
- }
- if (match.first == ts.npos)
- break;
- ts.erase(match.first, match.second);
- ts.insert(match.first, "\1");
- }
- for (auto c : ts)
- {
- if (c != '\1')
- {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement