# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1067371 | AlgorithmWarrior | Mutating DNA (IOI21_dna) | C++17 | 29 ms | 9824 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 "dna.h"
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;
int sp[MAX][3][3];
int sp1[MAX][3];
int sp2[MAX][3];
void init(string a, string b)
{
int to[100];
to['A']=0;
to['C']=1;
to['T']=2;
int n=a.size();
int i,j,k;
for(i=1;i<=n;++i)
{
++sp[i][to[a[i-1]]][to[b[i-1]]];
++sp1[i][to[a[i-1]]];
++sp2[i][to[b[i-1]]];
for(j=0;j<3;++j)
sp1[i][j]+=sp1[i-1][j];
for(j=0;j<3;++j)
sp2[i][j]+=sp2[i-1][j];
for(j=0;j<3;++j)
for(k=0;k<3;++k)
sp[i][j][k]+=sp[i-1][j][k];
}
}
int get_distance(int x, int y)
{
++x,++y;
int i,j;
for(i=0;i<3;++i)
if(sp1[y][i]-sp1[x-1][i]!=sp2[y][i]-sp2[x-1][i])
return -1;
int nr=abs(sp[y][0][1]-sp[x-1][0][1]-sp[y][1][0]+sp[x-1][1][0]);
int cnt=2*nr;
for(i=0;i<3;++i)
for(j=i+1;j<3;++j)
cnt+=min(sp[y][i][j]-sp[x-1][i][j],sp[y][j][i]-sp[x-1][j][i]);
return cnt;
}
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... |