Code Submission Evaluation System Login

HIIT Open 2016

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

Tasks | Messages | Scoreboard | Statistics


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

Test results

testverdicttime (s)
#1ACCEPTED0.18 / 1.00details

Code

#include <bits/stdc++.h>

using namespace std;


string s;

vector<int> ans[11];
int n;

void Load()
{
	cin >> s;
	n = s.length();
}


int Encode(string &s, int l, int r) {
	int ans = 0;
	for (int i = l; i < r; i++) {
		ans *= 4;
		if (s[i] == 'A') ans += 0;
		if (s[i] == 'T') ans += 1;
		if (s[i] == 'G') ans += 2;
		if (s[i] == 'C') ans += 3;
	}
	return ans;
}

void Solve() {
	int i, j;
	for (i = 1; i <= 10; i++) {
		ans[i].resize(1 << (2*i));
		for (j = 0; j < n - i; j++) {
		  ans[i][Encode(s, j, j+i)] = 1;
		}
	}
	cin >> j;
	for (i = 0; i < j; i++) {
		string ss;
		cin >> ss;
		int k = ss.length();
		if (ans[k][Encode(ss, 0, k)])
			cout << "YES\n";
		else
		  cout << "NO\n";
	}
}

int main(){
 Load(); 
 Solve();
 return 0;
}

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