# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642536 | daisy2 | Mutating DNA (IOI21_dna) | C++17 | 32 ms | 7944 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<iostream>
using namespace std;
int pr[100005][3][3],brl[2][100005][3];
void init(std::string a, std::string b) {
int in1,in2;
for(int i=0;i<a.size();i++)
{
if(a[i]=='A') in1=0;
else if(a[i]=='T') in1=1;
else in1=2;
if(b[i]=='A') in2=0;
else if(b[i]=='T') in2=1;
else in2=2;
if(in1==in2) continue;
if(i!=0){
for(int j1=0;j1<=3;j1++)
{
for(int j2=0;j2<=3;j2++)
pr[i][j1][j2]=pr[i-1][j1][j2];
}
for(int j1=0;j1<=1;j1++)
{
for(int j2=0;j2<=2;j2++)
brl[j1][i][j2]=brl[j1][i-1][j2];
}
}
pr[i][in1][in2]++;
brl[0][i][in1]++;
brl[1][i][in2]++;
}
}
int get_distance(int x, int y) {
int minim=0,minim2=0;
for(int let=0;let<=2;let++)
{
if(x>0) {minim=brl[0][x-1][let];minim2=brl[1][x-1][let];}
if(brl[0][y][let]-minim!=brl[1][y][let]-minim2)
return -1;
}
int t01=pr[y][0][1],t10=pr[y][1][0],t02=pr[y][0][2],t20=pr[y][2][0],t12=pr[y][1][2],t21=pr[y][2][1];
if(x>0) {t01-=pr[x-1][0][1];t10-=pr[x-1][1][0];t02-=pr[x-1][0][2];t20-=pr[x-1][2][0];t12-=pr[x-1][1][2];t21-=pr[x-1][2][1];}
int m1=min(t01,t10);
int m2=min(t02,t20);
int m3=min(t12,t21),r;
return m1+m2+m3+2*(max(t01,t10)-m1);
}
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... |