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 <map>
#include <vector>
const int MAXN = 1e5 + 5;
std::vector<std::map<char, int>> aDP(MAXN);
std::vector<std::map<char, int>> bDP(MAXN);
void init(std::string a, std::string b) {
for (int i = 0; i < (int) a.length(); ++i)
{
aDP[i + 1] = aDP[i];
bDP[i + 1] = bDP[i];
if (a[i] != b[i])
{
aDP[i + 1][a[i]]++;
bDP[i + 1][b[i]]++;
}
}
}
int get_distance(int x, int y) {
y++;
int aAcumA = aDP[y]['A'] - aDP[x]['A'];
int aAcumC = aDP[y]['C'] - aDP[x]['C'];
int aAcumT = aDP[y]['T'] - aDP[x]['T'];
int bAcumA = bDP[y]['A'] - bDP[x]['A'];
int bAcumC = bDP[y]['C'] - bDP[x]['C'];
int bAcumT = bDP[y]['T'] - bDP[x]['T'];
if (aAcumA != bAcumA || aAcumC != bAcumC || aAcumT != bAcumT) return -1;
int total = aAcumA + aAcumC + aAcumT;
int moves = (total >> 1);
return (total & 1) ? moves + 1 : moves;
}
# | 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... |