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>
#include "dna.h"
using namespace std;
#define f(i,a,b) for(int i = a; i < b; i++)
const int N = 1e5 + 5;
int n, su[N][6];
string s, t;
void init(string a, string b){
s = a, t = b, n = a.size();
f(i,1,n+1){
f(j,0,6) su[i][j] = su[i-1][j];
if(s[i-1] == 'A' and t[i-1] == 'C') su[i][0]++;
if(s[i-1] == 'A' and t[i-1] == 'T') su[i][1]++;
if(s[i-1] == 'C' and t[i-1] == 'A') su[i][2]++;
if(s[i-1] == 'C' and t[i-1] == 'T') su[i][3]++;
if(s[i-1] == 'T' and t[i-1] == 'A') su[i][4]++;
if(s[i-1] == 'T' and t[i-1] == 'C') su[i][5]++;
}
}
int get_distance(int x, int y){
x++, y++;
int ac, at, ca, ct, ta, tc;
ac =su[y][0]-su[x-1][0]; at =su[y][1]-su[x-1][1]; ca =su[y][2]-su[x-1][2];
ct =su[y][3]-su[x-1][3]; ta =su[y][4]-su[x-1][4]; tc =su[y][5]-su[x-1][5];
if(ac + at != ca + ta or ct + ca != ac + tc or ta + tc != ct + at) return -1;
int add = max(ac, ca) - min(ac, ca), ans;
ans = min(ac, ca) + min(at, ta) + min(ct, tc);
return ans + add*2;
}
# | 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... |