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 <bits/stdc++.h>
using namespace std;
#include "dna.h"
int A[100003],B[100003],n;
void init(string a, string b) {
n = a.size();
for(int i = 0; i < n; i++){
if(a[i]=='A') A[i+1] = 1;
if(a[i]=='T') A[i+1] = 2;
if(a[i]=='C') A[i+1] = 3;
if(b[i]=='A') B[i+1] = 1;
if(b[i]=='T') B[i+1] = 2;
if(b[i]=='C') B[i+1] = 3;
}
}
int get_distance(int x, int y) {
int sol = 0,a[4],b[4],x1=0,y1=0,z=0,t=0,u=0,v=0;
a[1] = 0; a[2] = 0; a[3] = 0; b[1] = 0; b[2] = 0; b[3] = 0;
for(int i = x+1; i <= y+1; i++){
a[A[i]]++; b[B[i]]++;
}
if((a[1]!=b[1])or(a[2]!=b[2])or(a[3]!=b[3])) sol = -1;
else{
for(int i = x+1; i <= y+1; i++){
if((A[i]==1)and(B[i]==2)) x1++;
if((A[i]==1)and(B[i]==3)) y1++;
if((A[i]==2)and(B[i]==1)) z++;
if((A[i]==2)and(B[i]==3)) t++;
if((A[i]==3)and(B[i]==1)) u++;
if((A[i]==3)and(B[i]==2)) v++;
}
sol = min(x1,z)+min(y1,u)+min(t,v)+2*(max(x1,z)-min(x1,z));
}
return sol;
}
# | 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... |