#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 1e6+5;
char l[maxn],s[maxn];
int _next[maxn] = {0};
int main(){
cin >> l+1;
cin >> s+1;
int ln = strlen(l+1),sn = strlen(s+1);
for(int i = 1; i <= sn; ++i) {
if(s[i] == 'A') s[i] = 'T';
else if(s[i] == 'T') s[i] = 'A';
else if(s[i] == 'C') s[i] = 'G';
else if(s[i] == 'G') s[i] = 'C';
}
int fr = 0;
for(int i = 2; i <= sn; ++i) {
while(fr && s[fr+1] != s[i]) {
fr = _next[fr];
}
if(s[fr+1] == s[i]) ++fr;
_next[i] = fr;
}
fr = 0;
for(int i = 1; i <= ln; ++i) {
while(fr && s[fr+1] != l[i]) {
fr = _next[fr];
}
if(s[fr+1] == l[i]) ++fr;
if(fr == sn) {
cout << i - sn + 1 <<endl;
return 0;
}
}
cout << 0 << endl;
return 0;
}
蓝桥6AC/C++ C.基因配对
最新推荐文章于 2022-05-30 00:00:00 发布