# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
812603 | abcvuitunggio | Mutating DNA (IOI21_dna) | C++17 | 39 ms | 6044 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],mx;
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']++;
}
}
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=mx=0;
d[0]=d[1]=d[2]=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;
mx=max(mx,max(cnt[i][j],cnt[j][i]));
d[i]+=cnt[i][j]-cnt[j][i];
d[j]+=cnt[j][i]-cnt[i][j];
}
return (d[0]|d[1]|d[2]?-1: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... |