# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
669801 | Marszpace | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 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<bool> diff;
string aGlobal,bGlobal;
void init(string a, string b){
for(int i=0;i<a.size();i++){
diff.push_back(!(a[i]==b[i]));
}
strcpy(a,aGlobal);
strcpy(b,bGlobal);
}
int get_distance(int x, int y){
int a[3],b[3];
for(int i=x;i<=y;i++){
if(aGlobal[i]=='A'){a[0]++;}
else if(aGlobal[i]=='T'){a[1]++;}
else if(aGlobal[i]=='C'){a[2]++;}
if(bGlobal[i]=='A'){b[0]++;}
else if(bGlobal[i]=='T'){b[1]++;}
else if(bGlobal[i]=='C'){b[2]++;}
}
if(a[0]!=b[0]||a[1]!=b[1]||a[2]!=b[2]){return -1;}
int res=0;
for(int i=x;i<=y;i++){
if(diff[i]){res++;}
}
return res/2;
}