#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define nmax 1000007
#define fi first
#define se second
#define ll long long
ll t=1,n,m,i,j,d=0,x=0,k=0,y,z,a[nmax],f[nmax][9],h[nmax][5],t1,t2,t3;
void init(string a,string b)
{
    n=a.size();
    a=' '+a;
    b=' '+b;
    for(i=1;i<=n;++i)
    {
        for(j=0;j<=5;++j)
        {
            f[i][j]=f[i-1][j];
            h[i][j]=h[i-1][j];
        }
        if(a[i]=='A')h[i][0]++;
        if(b[i]=='A')h[i][0]--;
        if(a[i]=='T')h[i][1]++;
        if(b[i]=='T')h[i][1]--;
        if(a[i]=='C')h[i][2]++;
        if(b[i]=='C')h[i][2]--;
        
        if(a[i]!=b[i])
        {
            if(a[i]=='A'&&b[i]=='T')f[i][0]++;
            if(a[i]=='A'&&b[i]=='C')f[i][1]++;
            if(a[i]=='T'&&b[i]=='A')f[i][2]++;
            if(a[i]=='T'&&b[i]=='C')f[i][3]++;
            if(a[i]=='C'&&b[i]=='A')f[i][4]++;
            if(a[i]=='C'&&b[i]=='T')f[i][5]++;
        }
    }
}
int get_distance(int x,int y)
{
    x++;
    y++;
    if(h[y][0]==h[x-1][0]||h[y][1]==h[x-1][1]||h[y][2]==h[x-1][2])return -1;
    ll d=0,k,f1[9];
    for(int i=0;i<6;++i)
    {
        f1[i]=f[y][i]-f[x-1][0];
    }
    k=min(f1[0],f1[2]);
    d+=k;
    f1[0]-=k;
    f1[2]-=k;
    k=min(f1[1],f1[4]);
    d+=k;
    f1[1]-=k;
    f1[4]-=k;
    k=min(f1[3],f1[5]);
    d+=k;
    f1[3]-=k;
    f1[5]-=k;
    for(int i=0;i<6;++i)d+=f1[i];
    return d;
}
| # | 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... |