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"
long long n,q;
std::string s;
std::string c;
void init(std::string a, std::string b) {
s=a,c=b;
while(q--){
int x,y;
get_distance(x,y);
}
}
int get_distance(int x, int y) {
int h1=0,h2=0,l1=0,l2=0,k1=0,k2=0;
for(int i=x;i<=y;i++){
if(s[i]=='A'){
h1++;
}else if(s[i]=='T'){
l1++;
}else if(s[i]=='C'){
k1++;
}
if(c[i]=='A'){
h2++;
}else if(c[i]=='T'){
l2++;
}else if(c[i]=='C'){
k2++;
}
}
if(h1==h2 && l1==l2 && k1==k2){
int j=0;
for(int i=x;i<=y;i++){
if(s[i]!=c[i]){
j+=1;
}
}
if(j%2==1){
j+=1;
}
return j/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... |