Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // DNA 비밀번호
- #include <iostream>
- #include <cstring>
- using namespace std;
- #include <fstream>
- #include <cstdio>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <stack>
- #include <queue>
- #include <functional>
- #include <deque>
- #include <numeric>
- #include <set>
- #include <climits>
- #include <utility>
- #include <map>
- #include <algorithm>
- #define INF 987654321
- #define MOD 1000000007
- typedef long long ll;
- typedef unsigned long long ull;
- inline int max( int x, int y ){ return x > y ? x : y ; }
- inline int min( int x, int y ){ return x < y ? x : y ; }
- inline ll max( ll x, ll y ){ return x > y ? x : y ; }
- inline ll min( ll x, ll y ){ return x < y ? x : y ; }
- inline ull max( ull x, ull y ){ return x > y ? x : y ; }
- inline ull min( ull x, ull y ){ return x < y ? x : y ; }
- int main(){
- int P, S;
- int A, C, G, T, ans=0;
- int cnt[4];
- char input[1000001];
- scanf("%d %d", &S, &P);
- fgetc(stdin);
- memset( input, 0, sizeof(input) );
- memset( cnt, 0, sizeof(cnt) );
- scanf("%s", input);
- scanf("%d %d %d %d", &A, &C, &G, &T);
- for( int i=0; i<P; ++i ){
- if( input[i] == 'A' ){
- cnt[0]++;
- }else if( input[i] == 'C' ){
- cnt[1]++;
- }else if( input[i] == 'G' ){
- cnt[2]++;
- }else{
- cnt[3]++;
- }
- }
- if( cnt[0] >= A && cnt[1] >= C && cnt[2] >= G && cnt[3] >= T ) ans++;
- for( int i=1; i<=(S-P); ++i ){
- if( input[i-1] == 'A' ){
- cnt[0]--;
- }else if( input[i-1] == 'C' ){
- cnt[1]--;
- }else if( input[i-1] == 'G' ){
- cnt[2]--;
- }else{
- cnt[3]--;
- }
- if( input[i+P-1] == 'A' ){
- cnt[0]++;
- }else if( input[i+P-1] == 'C' ){
- cnt[1]++;
- }else if( input[i+P-1] == 'G' ){
- cnt[2]++;
- }else{
- cnt[3]++;
- }
- if( cnt[0] >= A && cnt[1] >= C && cnt[2] >= G && cnt[3] >= T ) ans++;
- }
- printf("%d", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement