#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
string d;
string f;
void init(std::string a, std::string b) {
d=a;
f=b;
}
int get_distance(int x, int y) {
int cout_a_d=0,cout_c_d=0,cout_t_d=0,cout_a_f=0,cout_c_f=0,cout_t_f=0;
for(int i=x; i<y+1; i++) {
if(d[i] == 'A'){
cout_a_d++;
}
else if(d[i]== 'T'){
cout_t_d++;
}
else{
cout_c_d++;
}
if(f[i] == 'A'){
cout_a_f++;
}
else if(f[i]== 'T'){
cout_t_f++;
}
else{
cout_c_f++;
}
}
if(cout_a_d != cout_a_f){
return -1;
}
if(cout_t_d != cout_t_f){
return -1;
}
if(cout_c_d != cout_c_f){
return -1;
}
int i,j;
i=j=y;
int count=0;
bool x_change = false;
while(i>=x){
if(x_change){
j=y;
x_change = false;
}
if(i>=x){
while(d[i]==f[j]){
count++;
i--;
x_change = true;
}
}
j--;
}
return count;
}
# | 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... |