-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12891
46 lines (42 loc) · 1.11 KB
/
12891
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int s,p;
cin>>s>>p;
string a;
cin>>a;
vector<int> con(4);
for(int i=0; i<4; i++){
cin>>con[i];
}
int start=0, end=p-1, count=0;
int flag[4]={0};
for(int j=start; j<start+p; j++){
if(a[j]=='A') flag[0]++;
else if(a[j]=='C') flag[1]++;
else if(a[j]=='G') flag[2]++;
else if(a[j]=='T') flag[3]++;
}
if(flag[0]>=con[0]&&flag[1]>=con[1]&&flag[2]>=con[2]&&flag[3]>=con[3]) count++;
while(end<s-1){
if(a[start]=='A') flag[0]--;
else if(a[start]=='C') flag[1]--;
else if(a[start]=='G') flag[2]--;
else if(a[start]=='T') flag[3]--;
start++;
end++;
if(a[end]=='A') flag[0]++;
else if(a[end]=='C') flag[1]++;
else if(a[end]=='G') flag[2]++;
else if(a[end]=='T') flag[3]++;
if(flag[0]>=con[0]&&flag[1]>=con[1]&&flag[2]>=con[2]&&flag[3]>=con[3]) count++;
}
cout<<count;
return 0;
}