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"
const int N = 100000;
using namespace std;
int abs_(int a) { return a > 0 ? a : -a; }
int pp[6][N];
void init(string aa, string bb) {
int n = aa.size(), h, i;
for (i = 0; i < n; i++)
if (aa[i] == 'A' && bb[i] == 'T')
pp[0][i] = 1;
else if (aa[i] == 'T' && bb[i] == 'A')
pp[1][i] = 1;
else if (aa[i] == 'T' && bb[i] == 'C')
pp[4][i] = 1;
else if (aa[i] == 'C' && bb[i] == 'T')
pp[5][i] = 1;
else if (aa[i] == 'C' && bb[i] == 'A')
pp[2][i] = 1;
else if (aa[i] == 'A' && bb[i] == 'C')
pp[3][i] = 1;
for (h = 0; h < 6; h++)
for (i = 1; i < n; i++)
pp[h][i] += pp[h][i - 1];
}
int kk[6];
int get_distance(int i, int j) {
int h;
for (h = 0; h < 6; h++)
kk[h] = pp[h][j] - (i == 0 ? 0 : pp[h][i - 1]);
if (kk[0] - kk[1] != kk[2] - kk[3] || kk[0] - kk[1] != kk[4] - kk[5])
return -1;
return min(kk[0], kk[1]) + min(kk[2], kk[3]) + min(kk[4], kk[5]) + abs_(kk[0] - kk[1]) * 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... |