Code Submission Evaluation System Login

CSES - HIIT Open 2016

HIIT Open 2016

Contest start:2016-05-28 11:00:00
Contest end:2016-05-28 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2016-05-28 11:59:42
Task:DNA sequence
Sender:LTR
Submission time:2016-05-28 11:59:42
Status:READY
Result:ACCEPTED

Show test data

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;
		}
	}
}