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:13:33
Task:DNA sequence
Sender:Barely Div 1
Submission time:2016-05-28 11:13:33
Status:READY
Result:ACCEPTED

Show test data

Code

#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(){
  string s; cin >> s;
  int n = s.size();
  int nQueries; cin >> nQueries;
  
  set<string> db;
  for(int L = 1; L <= 10; L++){
    for(int i = 0; i < n; i++){
      db.insert(s.substr(i,L));
    }
  }
  
  for(int i = 0; i < nQueries; i++){
    string query; cin >> query;
    if(db.count(query)) cout << "YES\n";
    else cout << "NO\n";
  }
}