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"
#include <iostream>
#include <vector>
using namespace std;
string A,B;
void init(std::string a, std::string b) {
A=a;B=b;
}
int get_distance(int x, int y) {
int C1[3]={0,0,0};
int C2[3]={0,0,0};
int dif=0;
for(int i=x;i<=y;i++){
if(A[i]=='A') C1[0]++;
if(A[i]=='T') C1[1]++;
if(A[i]=='C') C1[2]++;
if(B[i]=='A') C2[0]++;
if(B[i]=='T') C2[1]++;
if(B[i]=='C') C2[2]++;
if(A[0]!=B[0]) dif++;
}
if((((A[0]>0 || A[1]>0) and A[2]==0)and((B[0]>0 || B[1]>0) and B[2]==0)) ){
if(A[0]==B[0] and A[1]==B[1]){
return dif/2;
}else{
return -1;
}
}
if(C1[0]!=C2[0] || C1[1]!=C2[1] || C1[2]!=C2[2]) return -1;
if(y-x<=2){
if(y-x==0) return 0;
if(y-x==1){
if(A[x]==B[x]) return 0;
return 1;
}
if(A[x]==B[x] && A[x+1]==B[x+1] && A[y]==B[y]) return 0;
if(A[x]==B[x] || A[x+1]==B[x+1] || A[y]==B[y]) return 1;
return 2;
}
if(C1[2]==0 && C2[2]==0){
int c=0;
for(int i=x;i<=y;i++)
if(A[i]!=B[i]) c++;
return c/2;
}
return 0;
}
# | 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... |