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"
int N;
int *anumA, *anumT, *anumC;
int *bnumA, *bnumT, *bnumC;
std::string A, B;
void init(std::string _a, std::string _b) {
A = std::move(_a);
B = std::move(_b);
N = A.size();
for (auto x: {&anumA, &anumT, &anumC, &bnumA, &bnumT, &bnumC}) {
*x = new int[N];
}
anumA[0] = A[0] == 'A';
anumT[0] = A[0] == 'T';
anumC[0] = A[0] == 'C';
bnumA[0] = B[0] == 'A';
bnumT[0] = B[0] == 'T';
bnumC[0] = B[0] == 'C';
for (int i = 1; i < N; ++i) {
anumA[i] = anumA[i - 1] + (A[i] == 'A');
anumT[i] = anumT[i - 1] + (A[i] == 'T');
anumC[i] = anumC[i - 1] + (A[i] == 'C');
bnumA[i] = bnumA[i - 1] + (B[i] == 'A');
bnumT[i] = bnumT[i - 1] + (B[i] == 'T');
bnumC[i] = bnumC[i - 1] + (B[i] == 'C');
}
}
int num(int *data, int l, int r) {
int x = data[r];
if (l) x -= data[l - 1];
return x;
}
int get_distance(int x, int y) {
int aa = num(anumA, x, y);
int ba = num(bnumA, x, y);
int at = num(anumT, x, y);
int bt = num(bnumT, x, y);
int ac = num(anumC, x, y);
int bc = num(bnumC, x, y);
if (aa != ba || at != bt || ac != bc) return -1;
if (y - x <= 2) {//Subtask 1
int d = 0;
for (int i = x; i <= y; ++i) {
d += A[i] != B[i];
}
return (d + 1) / 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... |