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

Code

#include <bits/stdc++.h>

using namespace std;
unordered_set<string> a;
int main(){
  cin.sync_with_stdio(0);
  cin.tie(0);
  string s; cin >> s;
  int n = s.length(), q;
  for(int i = 1; i <= 10; i++){
      for(int j = 0; j + i - 1 < n; j++)
	a.insert(s.substr(j, i));
  }
  cin >> q;
  while(q--){
    string qs; cin >> qs;
    if(a.count(qs))
      printf("YES\n");
    else
      printf("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
...