#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
const int maxn=1e5+10;
int prefall[maxn];
int pref[2][3][maxn];
///A
///C
///T
void init(string a,string b)
{
for(int i=0;i<a.size();i++)
{
if(i!=0){
pref[0][0][i]=pref[0][0][i-1];
pref[0][1][i]=pref[0][1][i-1];
pref[0][2][i]=pref[0][2][i-1];}
if(a[i]=='A') pref[0][0][i]++;
if(a[i]=='C') pref[0][1][i]++;
if(a[i]=='T') pref[0][2][i]++;
}
for(int i=0;i<b.size();i++)
{
if(i!=0){
pref[1][0][i]=pref[1][0][i-1];
pref[1][1][i]=pref[1][1][i-1];
pref[1][2][i]=pref[1][2][i-1];}
if(b[i]=='A') pref[1][0][i]++;
if(b[i]=='C') pref[1][1][i]++;
if(b[i]=='T') pref[1][2][i]++;
if(i!=0) prefall[i]=prefall[i-1];
if(a[i]!=b[i]) prefall[i]++;
}
}
int get_distance(int x,int y)
{
if(x!=0){
if(pref[0][0][y]-pref[0][0][x-1]!=pref[1][0][y]-pref[1][0][x-1]) return -1;
if(pref[0][1][y]-pref[0][1][x-1]!=pref[1][1][y]-pref[1][1][x-1]) return -1;
if(pref[0][2][y]-pref[0][2][x-1]!=pref[1][2][y]-pref[1][2][x-1]) return -1;}
else
{
if(pref[0][0][y]!=pref[1][0][y]) return -1;
if(pref[0][1][y]!=pref[1][1][y]) return -1;
if(pref[0][2][y]!=pref[1][2][y]) return -1;
}
if(x==0) return max(0,prefall[y]-1);
return max(0,prefall[y]-prefall[x-1]-1);
}
/*
TACAT TACAT TACAT TACAT
CTATA CAATT AACTT TACAT*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |