이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |