이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
vector<array<int, 9>> cou;
int getInd(char c) {
if (c == 'A') return 0;
if (c == 'C') return 1;
if (c == 'T') return 2;
assert(false);
return -1;
}
void init(string a, string b) {
int n = a.size();
cou.resize(n + 1);
for (int x = 0; x < 9; ++x) cou[0][x] = 0;
for (int j = 1; j <= n; ++j) {
for (int x = 0; x < 9; ++x) cou[j][x] = cou[j-1][x];
int va = getInd(a[j-1]);
int vb = getInd(b[j-1]);
++cou[j][va + 3*vb];
}
}
int get_distance(int x, int y) {
array<int, 9> counts = cou[y + 1];
for (int j = 0; j < 9; ++j) counts[j] -= cou[x][j];
int ab = counts[1];
int ac = counts[2];
int ba = counts[3];
int bc = counts[5];
int ca = counts[6];
int cb = counts[7];
int diff_a = ab + ac - ba - ca;
int diff_b = ba + bc - ab - cb;
int diff_c = ca + cb - ac - bc;
if (diff_a != 0 || diff_b != 0 || diff_c != 0) return -1;
int abba = min(ab, ba);
int acca = min(ac, ca);
int bccb = min(bc, cb);
int res = abba + acca + bccb;
ab -= abba;
ba -= abba;
ac -= acca;
ca -= acca;
bc -= bccb;
cb -= bccb;
int abc = min(ab, min(bc, ca));
int acb = min(ac, min(cb, ba));
res += 2 * (abc + acb);
ab -= abc;
bc -= abc;
ca -= abc;
ac -= acb;
cb -= acb;
ba -= acb;
assert(ab == 0 && bc == 0 && ca == 0 && ac == 0 && cb == 0 && ba == 0);
return res;
}
# | 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... |