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;
const int MAX_N = 1e5 + 10;
int N;
int preT1[MAX_N], preA1[MAX_N], preC1[MAX_N];
int preT2[MAX_N], preA2[MAX_N], preC2[MAX_N];
int preTA[MAX_N], preAT[MAX_N];
void init(string a, string b) {
N = a.length();
for(int i = 1; i <= N; i++) {
preT1[i] = preT1[i - 1] + (a[i - 1] == 'T');
preT2[i] = preT2[i - 1] + (b[i - 1] == 'T');
preA1[i] = preA1[i - 1] + (a[i - 1] == 'A');
preA2[i] = preA2[i - 1] + (b[i - 1] == 'A');
preC1[i] = preC1[i - 1] + (a[i - 1] == 'C');
preC2[i] = preC2[i - 1] + (b[i - 1] == 'C');
preTA[i] = preTA[i - 1] + (a[i - 1] == 'T' and b[i - 1] == 'A');
preAT[i] = preAT[i - 1] + (a[i - 1] == 'A' and b[i - 1] == 'T');
}
}
int range(int x, int y, int *a) {
return a[y + 1] - a[x];
}
int get_distance(int x, int y) {
if(range(x, y, preT1) != range(x, y, preT2) or range(x, y, preA1) != range(x, y, preA2) or range(x, y, preC1) != range(x, y, preC2)) {
return -1;
}
return min(range(x, y, preTA), range(x, y, preAT));
}
# | 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... |