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:11:03
Task:DNA sequence
Sender:Oispa Kaljaa
Submission time:2016-05-28 11:11:03
Status:READY
Result:ACCEPTED

Show test data

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