CSES - HIIT Open 2016 - Results
Submission details
Task:DNA sequence
Sender:LTR
Submission time:2016-05-28 11:59:42 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.66 sdetails

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

Test details

Test 1

Verdict: ACCEPTED

input
ACGCGGGCTCCTAGCGTTAGCAGTTGAGTG...

correct output
YES
YES
NO
NO
YES
...

user output
YES
YES
NO
NO
YES
...