Task: | DNA sequence |
Sender: | guq2 |
Submission time: | 2016-10-22 16:01:33 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.70 s | details |
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; } } }