Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. // DNA 비밀번호
  2.  
  3. #include <iostream>
  4. #include <cstring>
  5. using namespace std;
  6. #include <fstream>
  7. #include <cstdio>
  8. #include <cmath>
  9. #include <ctime>
  10. #include <vector>
  11. #include <stack>
  12. #include <queue>
  13. #include <functional>
  14. #include <deque>
  15. #include <numeric>
  16. #include <set>
  17. #include <climits>
  18. #include <utility>
  19. #include <map>
  20. #include <algorithm>
  21. #define INF 987654321
  22. #define MOD 1000000007
  23. typedef long long ll;
  24. typedef unsigned long long ull;
  25. inline int max( int x, int y ){ return x > y ? x : y ; }
  26. inline int min( int x, int y ){ return x < y ? x : y ; }
  27. inline ll max( ll x, ll y ){ return x > y ? x : y ; }
  28. inline ll min( ll x, ll y ){ return x < y ? x : y ; }
  29. inline ull max( ull x, ull y ){ return x > y ? x : y ; }
  30. inline ull min( ull x, ull y ){ return x < y ? x : y ; }
  31.  
  32.  
  33. int main(){
  34.  
  35. int P, S;
  36. int A, C, G, T, ans=0;
  37. int cnt[4];
  38. char input[1000001];
  39.  
  40. scanf("%d %d", &S, &P);
  41. fgetc(stdin);
  42. memset( input, 0, sizeof(input) );
  43. memset( cnt, 0, sizeof(cnt) );
  44. scanf("%s", input);
  45. scanf("%d %d %d %d", &A, &C, &G, &T);
  46.  
  47. for( int i=0; i<P; ++i ){
  48. if( input[i] == 'A' ){
  49. cnt[0]++;
  50. }else if( input[i] == 'C' ){
  51. cnt[1]++;
  52. }else if( input[i] == 'G' ){
  53. cnt[2]++;
  54. }else{
  55. cnt[3]++;
  56. }
  57. }
  58.  
  59. if( cnt[0] >= A && cnt[1] >= C && cnt[2] >= G && cnt[3] >= T ) ans++;
  60. for( int i=1; i<=(S-P); ++i ){
  61. if( input[i-1] == 'A' ){
  62. cnt[0]--;
  63. }else if( input[i-1] == 'C' ){
  64. cnt[1]--;
  65. }else if( input[i-1] == 'G' ){
  66. cnt[2]--;
  67. }else{
  68. cnt[3]--;
  69. }
  70.  
  71. if( input[i+P-1] == 'A' ){
  72. cnt[0]++;
  73. }else if( input[i+P-1] == 'C' ){
  74. cnt[1]++;
  75. }else if( input[i+P-1] == 'G' ){
  76. cnt[2]++;
  77. }else{
  78. cnt[3]++;
  79. }
  80. if( cnt[0] >= A && cnt[1] >= C && cnt[2] >= G && cnt[3] >= T ) ans++;
  81. }
  82. printf("%d", ans);
  83. return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement