# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
812588 | abcvuitunggio | Mutating DNA (IOI21_dna) | C++17 | 33 ms | 7376 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>
using namespace std;
int s[100001][3][3],cnt[3][3],n,res,d[3];
void init(string a, string b){
n=a.length();
for (int i=0;i<n;i++){
if (a[i]=='T')
a[i]='B';
if (b[i]=='T')
b[i]='B';
for (int j=0;j<3;j++)
for (int k=0;k<3;k++)
s[i][j][k]=s[i-1][j][k];
s[i][a[i]-'A'][b[i]-'A']++;
for (int j=0;j<3;j++)
s[i][j][j]=0;
}
}
int get_distance(int x, int y){
for (int i=0;i<3;i++)
for (int j=0;j<3;j++)
cnt[i][j]=s[y][i][j]-(x?s[x-1][i][j]:0);
res=0;
for (int i=0;i<3;i++)
for (int j=i+1;j<3;j++){
int val=min(cnt[i][j],cnt[j][i]);
cnt[i][j]-=val;
cnt[j][i]-=val;
res+=val;
}
int mx=0;
d[0]=d[1]=d[2]=0;
for (int i=0;i<3;i++)
for (int j=0;j<3;j++){
d[i]+=cnt[i][j];
d[j]-=cnt[i][j];
mx=max(mx,cnt[i][j]);
}
if (d[0]|d[1]|d[2])
return -1;
return mx*2+res;
}
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... |