This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "dna.h"
using namespace std;
const long long ma=3;
const string ky="ATC";
long long n,ps[ma][ma][100069],fq[ma][ma];
inline long long yk(char ch)
{
long long i;
for(i=0;i<ma;i++)
{
if(ky[i]==ch)
{
return i;
}
}
return -1;
}
void init(string s,string s2)
{
long long i,j,r,k,l;
n=s.length();
for(i=1;i<=n;i++)
{
k=yk(s[i-1]);
l=yk(s2[i-1]);
for(j=0;j<ma;j++)
{
for(r=0;r<ma;r++)
{
ps[j][r][i]=ps[j][r][i-1];
}
}
ps[k][l][i]++;
}
}
int get_distance(int lb,int rb)
{
long long i,j,k,l,w,sm,z=0;
lb++;
rb++;
for(i=0;i<ma;i++)
{
for(j=0;j<ma;j++)
{
fq[i][j]=ps[i][j][rb]-ps[i][j][lb-1];
}
}
for(i=0;i<ma;i++)
{
sm=0;
for(j=0;j<ma;j++)
{
sm+=fq[i][j]-fq[j][i];
}
if(sm)
{
return -1;
}
}
for(i=0;i<ma;i++)
{
l=(i+1)%ma;
w=min(fq[i][l],fq[l][i]);
z+=w;
fq[i][l]-=w;
fq[l][i]-=w;
k=max(fq[i][l],fq[l][i]);
}
z+=k*2;
return z;
}
# | 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... |