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 "dna.h"
#include <cstdio>
#include <cassert>
#include <string>
#include <vector>
int nr[100010][50],l;
inline int cod(char a)
{
if(a=='A')
return 1;
if(a=='T')
return 2;
if(a=='C')
return 3;
}
void init(std::string a, std::string b) {
for(;a[l];++l)
{
for(int i=0;i<=3;++i)
for(int j=0;j<=3;++j)
nr[l+1][i*10+j]=nr[l][i*10+j];
++nr[l+1][cod(a[l])*10];
++nr[l+1][cod(b[l])];
++nr[l+1][cod(a[l])*10+cod(b[l])];
}
}
int get_distance(int x, int y) {
++x;
++y;
if(nr[y][10]-nr[x-1][10]!=nr[y][1]-nr[x-1][1]||nr[y][20]-nr[x-1][20]!=nr[y][2]-nr[x-1][2]||nr[y][30]-nr[x-1][30]!=nr[y][3]-nr[x-1][3])
return -1;
int a=nr[y][12]-nr[x-1][12];
int b=nr[y][13]-nr[x-1][13];
int c=nr[y][21]-nr[x-1][21];
int d=nr[y][23]-nr[x-1][23];
int e=nr[y][31]-nr[x-1][31];
int f=nr[y][32]-nr[x-1][32];
int ans=0;
int adans=0;
adans=std::min(a,c);
ans+=adans;
a-=adans;
c-=adans;
adans=std::min(b,e);
ans+=adans;
b-=adans;
e-=adans;
adans=std::min(d,f);
ans+=adans;
d-=adans;
f-=adans;
ans+=(a+b)*2;
return ans;
}
Compilation message (stderr)
dna.cpp: In function 'int cod(char)':
dna.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
16 | }
| ^
# | 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... |