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 <iostream>
#include <vector>
int N;
std::string A, B;
std::vector<int> wrongA = {0};
std::vector<int> wrongT = {0};
void init(std::string a, std::string b)
{
A = a;
B = b;
N = a.size();
wrongA.resize(N + 1);
wrongT.resize(N + 1);
for (int i = 1; i <= N; ++i)
wrongA[i] = wrongA[i - 1] + (A[i-1] == 'A' && B[i-1] == 'T'),
wrongT[i] = wrongT[i - 1] + (A[i-1] == 'T' && B[i-1] == 'A');
}
int get_distance(int x, int y)
{
if (wrongA[y + 1] - wrongA[x] != wrongT[y + 1] - wrongT[x])
return -1;
return wrongA[y + 1] - wrongA[x];
}
# | 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... |