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"
#include <cassert>
const int maxn = 1e5+5;
std::string a, b; // 1-index
int d1[maxn], d2[maxn], sm[maxn], n;
void init(std::string A, std::string B) {
a = A, b = B, n = A.size();
for (int i=1;i<=n;i++) {
assert(A[i-1]!='C'&&B[i-1]!='C');
if (A[i-1]==B[i-1]) sm[i] = sm[i-1]+1;
else if (A[i-1]=='A') d1[i] = d1[i-1]+1;
else d2[i] = d2[i-1]+1;
}
}
int get_distance(int x, int y) {
x++, y++;
int cd1 = d1[y]-d1[x-1], cd2 = d2[y]-d2[x-1];
if (cd1!=cd2) return -1;
return cd1;
}
# | 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... |