# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1072021 | Ahmed57 | Mutating DNA (IOI21_dna) | C++17 | 42 ms | 8524 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;
vector<int> A,B;
int lo[100001][3][3];
void init(string a, string b){
for(auto i:a){
if(i=='A')A.push_back(0);
else if(i=='T')A.push_back(1);
else A.push_back(2);
}
for(auto i:b){
if(i=='A')B.push_back(0);
else if(i=='T')B.push_back(1);
else B.push_back(2);
}
for(int i = 0;i<A.size();i++){
lo[i][A[i]][B[i]]++;
if(i){
for(int e = 0;e<3;e++)for(int g = 0;g<3;g++)lo[i][e][g]+=lo[i-1][e][g];
}
}
}
int get_distance(int x, int y){
long long all =0;
int lol[3][3];
for(int i = 0;i<3;i++){
for(int j = 0;j<3;j++){
lol[i][j] = lo[y][i][j];
if(x){
lol[i][j]-=lo[x-1][i][j];
}
}
}
int aa[3] = {0};
int bb[3] = {0};
for(int i = 0;i<3;i++){
for(int j = 0;j<3;j++){
aa[i]+=lol[i][j];
bb[j]+=lol[i][j];
}
}
for(int i = 0;i<3;i++){
if(aa[i]!=bb[i])return -1;
}
for(int i = 0;i<3;i++){
lol[i][i] = 0;
for(int j = i+1;j<3;j++){
int mi = min(lol[i][j],lol[j][i]);
all+=mi;
lol[i][j]-=mi;
lol[j][i]-=mi;
}
}
int su = 0;
for(int i = 0;i<3;i++){
for(int j = 0;j<3;j++){
su+=lol[i][j];
}
}
all+=su/3*2;
return all;
}
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... |