Code Submission Evaluation System Login

HIIT Open 2016

 Start: 2016-05-28 11:00:00 End: 2016-05-28 16:00:00

CSES - HIIT Open 2016 - Results
History
2016-05-28 11:15:55
 Task: DNA sequence Sender: Anonyymit Algoritmistit Submission time: 2016-05-28 11:15:55 Language: C++ Status: READY Result: ACCEPTED

Test results

 test verdict time (s) #1 ACCEPTED 0.18 / 1.00 details

Code

```#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
typedef long long ll;

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

string s;
cin >> s;

int n = s.length();
int q;
cin >> q;

unordered_set<ll> hashes;

for (int i = 1; i <= 10; ++i) {
for (int j = 0; j < n - i; ++j) {
int x = 1;
int v = 0;
for (int k = j; k < j+i; ++k) {
if (s[k] == 'A')
v += x*1;
else if (s[k] == 'C')
v += x*2;
else if (s[k] == 'G')
v += x*3;
else
v += x*4;
x *= 10;
}
hashes.insert(v);
}
}

for (int i = 0; i < q; ++i) {
string t;
cin >> t;
int m = t.length();
int v = 0;
int x = 1;
for (int k = 0; k < m; ++k) {
if (t[k] == 'A')
v += x*1;
else if (t[k] == 'C')
v += x*2;
else if (t[k] == 'G')
v += x*3;
else
v += x*4;
x *= 10;
}
if (hashes.count(v))
cout << "YES\n";
else
cout << "NO\n";
}

}```

Test details

Test 1

Verdict: ACCEPTED

input
`ACGCGGGCTCCTAGCGTTAGCAGTTGAGTG...`
view   save

correct output
```YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES ...```
view   save

user output
```YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES ...```
view   save