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 <bits/stdc++.h>
using namespace std;
string A, B;
void init(string a, string b) {
A = a; B = b;
}
int get_distance(int x, int y) {
int diff = 0;
int st1[3] = {0, 0, 0};
int st2[3] = {0, 0, 0};
for(int i=x; i<=y; i++) {
if(A[i] == 'A') st1[0]++;
else if(A[i] == 'T') st1[1]++;
else if(A[i] == 'C') st1[2]++;
/*-------------------------*/
if(B[i] == 'A') st2[0]++;
else if(B[i] == 'T') st2[1]++;
else if(B[i] == 'C') st2[2]++;
if(A[i] != B[i])diff++;
}
if(st1[0] != st2[0] || st1[1] != st2[1] || st1[2] != st2[2]) return -1;
if(y-x <= 2){
if(y-x == 0)return 0;
if(y-x == 1){
if(A[x] == B[x])return 0;
else return 1;
}
if(A[x] == B[x] && A[x+1] == B[x+1] && A[y] == B[y]) return 0;
else if(A[x] == B[x] || A[x+1] == B[x+1] || A[y] == B[y]) return 1;
else return 2;
}
//case 3
if(st1[2] == 0 && st2[2] == 0)return diff/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... |