# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
670490 | Desh03 | DNA 돌연변이 (IOI21_dna) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> v, a1, a2, c1, c2, t1, t2, m;
void init(string a, string b) {
x = a, y = b;
int n = a.size();
v.resize(n);
a1.resize(n + 1);
a2 = c1 = c2 = t1 = t2 = m = a1;
for (int i = 0; i < n; i++) {
a1[i + 1] = a1[i] + (a[i] == 'A');
a2[i + 1] = a2[i] + (b[i] == 'A');
c1[i + 1] = c1[i] + (a[i] == 'C');
c2[i + 1] = c2[i] + (b[i] == 'C');
t1[i + 1] = t1[i] + (a[i] == 'T');
t2[i + 1] = t2[i] + (b[i] == 'T');
m[i + 1] = m[i] + (a[i] != b[i]);
}
}
int get_distance(int x, int y) {
x++, y++;
int d1 = a2[y] - a2[x - 1], d2 = a1[y] - a1[x - 1];
int d3 = c2[y] - c2[x - 1], d4 = c1[y] - c1[x - 1];
int d5 = t2[y] - t2[x - 1], d6 = t1[y] - t1[x - 1];
if (d1 != d2 || d3 != d4 || d5 != d6) {
return -1;
} else {
return ((m[y] - m[x - 1] + 1) / 2);
}
}