Task: | DNA sequence |
Sender: | LTR |
Submission time: | 2016-05-28 11:59:42 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.66 s | details |
Code
#include <iostream> #include <vector> #include <cstdio> #include <string> #include <set> int main() { std::string s; std::cin >> s; int n = s.size(); int q; std::cin >> q; std::set<std::string> subs; for (int k = 1; k <= 10; ++k) { for (int i = 0; i < (n-k); ++i) { subs.insert(s.substr(i, k)); } } for (int i = 0; i < q; ++i) { std::string r; std::cin >> r; if (subs.find(r) != subs.end()) { std::cout << "YES" << std::endl; } else { std::cout << "NO" << std::endl; } } }