CSES - E4590 2016 6 - Results
Submission details
Task:DNA sequence
Sender:guq2
Submission time:2016-10-22 16:01:33 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.70 sdetails

Compiler report

input/code.cpp: In function 'void cal_hash(std::string)':
input/code.cpp:13:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; (i<=seq.length()) && (i<=10); ++i){
                                 ^
input/code.cpp:14:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<seq.length()-i; ++j){
                               ^

Code

#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <string.h>
using namespace std;


map<string, bool> mymap;

void cal_hash(string seq){
	string str;
	for (int i = 1; (i<=seq.length()) && (i<=10); ++i){
		for(int j=0; j<seq.length()-i; ++j){
			str = seq.substr(j,i);
			mymap[str]=true;
		}	
	}
}

int main(int argc, char const *argv[])
{
	int q;
	string seq, query;

	while(cin>>seq){
		cal_hash(seq);
		cin>>q;
		while(q--){
			cin>>query;
			if(mymap.find(query)!=mymap.end())
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
	}
}

Test details

Test 1

Verdict: ACCEPTED

input
ACGCGGGCTCCTAGCGTTAGCAGTTGAGTG...

correct output
YES
YES
NO
NO
YES
...

user output
YES
YES
NO
NO
YES
...