# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530882 | knon0501 | Mutating DNA (IOI21_dna) | C++17 | 61 ms | 9940 KiB |
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>
using namespace std;
int sa[100005][3];
int sb[100005][3];
int e[100005][3][3];
int c[200];
int n;
string a,b;
void init(std::string aa, std::string bb) {
a=aa;
b=bb;
n=a.length();
c['A']=0;
c['T']=1;
c['C']=2;
for(int i=1 ; i<=n ; i++){
sa[i][0]=sa[i-1][0];
sb[i][0]=sb[i-1][0];
sa[i][1]=sa[i-1][1];
sb[i][1]=sb[i-1][1];
sa[i][2]=sa[i-1][2];
sb[i][2]=sb[i-1][2];
sa[i][c[a[i-1]]]++;
sb[i][c[b[i-1]]]++;
for(int j=0 ; j<3 ; j++)
for(int k=0 ; k<3 ; k++)
e[i][j][k]=e[i-1][j][k];
e[i][c[a[i-1]]][c[b[i-1]]]++;
}
}
int get_distance(int x, int y) {
x++;
y++;
for(int i=0 ; i<3 ; i++)
if(sa[y][i]-sa[x-1][i]!=sb[y][i]-sb[x-1][i])return -1;
int d[3][3]={0,};
for(int i=0 ; i<3 ; i++)
for(int j=0 ; j<3 ; j++)
d[i][j]=e[y][i][j]-e[x-1][i][j];
int ans=0;
int cnt=0;
for(int i=0 ; i<3 ; i++){
for(int j=0 ; j<3 ; j++){
int k=min(d[i][j],d[j][i]);
d[i][j]-=k;
if(i!=j)
d[j][i]-=k;
if(i!=j)
ans+=k;
cnt+=d[i][j];
}
}
return ans+cnt*2/3;
}
Compilation message (stderr)
# | 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... |