# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440775 | jlozano254 | Mutating DNA (IOI21_dna) | C++17 | 196 ms | 44188 KiB |
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>
std::vector<std::map<char, int>> aDP;
std::vector<std::map<char, int>> bDP;
void init(std::string a, std::string b) {
std::vector<std::map<char, int>> aux(a.length() + 1);
aDP = aux;
bDP = aux;
if (a[0] != b[0]) {
aDP[1][a[0]]++;
bDP[1][b[0]]++;
}
for (int i = 1; i < 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;
}
Compilation message (stderr)
# | 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... |