Created
March 3, 2015 07:54
-
-
Save ShaderManager/9d6bc4250fa8d52d7830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment