# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
558555 | pawned | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
void init(std::string a, std::string b) {
int N = a.size();
int pfs1[N + 1][3];
pfs1[0][0] = 0;
pfs1[0][1] = 0;
pfs1[0][2] = 0;
int pfs2[N + 1][3];
pfs2[0][0] = 0;
pfs2[0][1] = 0;
pfs2[0][2] = 0;
for (int i = 1; i <= N; i++) {
if (a[i - 1] == 'A')
pfs1[i][0] = pfs1[i - 1][0] + 1;
if (a[i - 1] == 'T')
pfs1[i][1] = pfs1[i - 1][1] + 1;
if (a[i - 1] == 'C')
pfs1[i][2] = pfs1[i - 1][2] + 1;
if (b[i - 1] == 'A')
pfs2[i][0] = pfs2[i - 1][0] + 1;
if (b[i - 1] == 'T')
pfs2[i][1] = pfs2[i - 1][1] + 1;
if (b[i - 1] == 'C')
pfs2[i][2] = pfs2[i - 1][2] + 1;
}
int pfs[N + 1];
pfs[0] = 0;
for (int i = 1; i <= N; i++) {
pfs[i] = pfs[i - 1];
if (a[i - 1] != b[i - 1])
pfs[i]++;
}
return;
}
int get_distance(int x, int y) {
bool works = true;
for (int i = 0; i < 3; i++) {
if (pfs1[y][i] - pfs[x - 1][i] != pfs2[y][i] - pfs2[x - 1][i])
works = false;
}
if (!works)
return -1;
else
return (pfs[y] - pfs[x - 1]);
}