#include "bits/stdc++.h"
using namespace std;
#include "dna.h"
string stringA;
string stringB;
vector<vector<int>> countD;
int ln;
void init(std::string a, std::string b) {
stringA = a;
stringB = b;
ln = a.size();
countD.resize(ln);
int at = 0;
int ta = 0;
int ac = 0;
int ca = 0;
int tc = 0;
int ct = 0;
for(int i=ln-1; i >= 0; i--){
if(a[i] == 'A' && b[i] == 'T'){
at +=1;
}if(a[i] == 'T' && b[i] == 'A'){
ta +=1;
}if(a[i] == 'A' && b[i] == 'C'){
ac +=1;
}if(a[i] == 'C' && b[i] == 'A'){
ca +=1;
}if(a[i] == 'T' && b[i] == 'C'){
tc +=1;
}if(a[i] == 'C' && b[i] == 'T'){
ct +=1;
}
countD[i] = {at, ta, ac, ca, tc, ct};
}
}
int get_distance(int x, int y) {
vector<int> count = countD[x];
if(y+1 < ln){
for(int i=0; i < count.size(); i++){
count[i] -= countD[y+1][i];
}
}
int out = 0;
out += min(count[0], count[1]);
int rest1 =abs(count[0] - count[1]);
out += min(count[2], count[3]);
int rest2 = abs(count[2]-count[3]);
out += min(count[4], count[5]);
int rest3 = abs(count[4] - count[5]);
if(rest1 == rest2 && rest2 == rest3){
return out+rest2*2;
}else{
return -1;
}
}
# | 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... |