# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
705487 | jakobrs | DNA 돌연변이 (IOI21_dna) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <xmmintrin.h>
#include <iostream>
#include <vector>
union Count {
__m128i simd;
struct {
int at, ca, tc;
int qw;
};
inline Count operator-(Count rhs) const {
return Count{.simd = _mm_sub_epi32(simd, rhs.simd)};
}
};
std::string a, b;
std::vector<Count> prefixes;
void init(std::string A, std::string B) {
a = A;
b = B;
prefixes.reserve(A.size() + 1);
prefixes.push_back(Count{});
Count count{.at = 0, .ca = 0, .tc = 0, .qw = 0};
for (int i = 0; i < A.size(); i++) {
if (A[i] == 'A' && B[i] == 'T') count.at += 1;
if (A[i] == 'T' && B[i] == 'A') count.at -= 1;
if (A[i] == 'C' && B[i] == 'A') count.ca += 1;
if (A[i] == 'A' && B[i] == 'C') count.ca -= 1;
if (A[i] == 'T' && B[i] == 'C') count.tc += 1;
if (A[i] == 'C' && B[i] == 'T') count.tc -= 1;
if (A[i] != B[i]) count.qw += 1;
prefixes.push_back(count);
}
}
int get_distance(int x, int y) {
y += 1;
Count count = prefixes[y] - prefixes[x];
if (!(count.at == count.ca && count.ca == count.tc)) return -1;
int total =
count.qw - std::abs(count.at) - std::abs(count.tc) - std::abs(count.ca);
total /= 2;
return total + std::abs(count.at) * 2;
}