CSES - E4590 2018 6 - Results
Submission details
Task:DNA sequence
Sender:Pohjantahti
Submission time:2018-10-20 13:28:02 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.41 sdetails

Code

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("arch=skylake")
#include <iostream>
#include <set>
#include <string>

using namespace std;

int n, q;
string s;
set<string> st;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	cin >> q;
	n = s.length();

	for (int cl = 1; cl <= 10; ++cl) {
		for (int i = 0; i < n-(cl-1); ++i) {
			st.insert(s.substr(i, cl));
		}
	}

	for (int cq = 0; cq < q; ++cq) {
		string cs;
		cin >> cs;
		if (st.find(cs) != st.end()) {
			cout << "YES\n";
		}
		else {
			cout << "NO\n";
		}
	}
	return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
ACGCGGGCTCCTAGCGTTAGCAGTTGAGTG...

correct output
YES
YES
NO
NO
YES
...

user output
YES
YES
NO
NO
YES
...