| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 670557 | sleepntsheep | DNA 돌연변이 (IOI21_dna) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
#define N 100005
#define ABS(x) ((x) < 0 ? (-(x)) : (x))
char a[N], b[N];
int unlike[N];
int counta[N][3];
int countb[N][3];
void init(string a_, string b_) {
strcpy(a+1, a_.c_str());
strcpy(b+1, b_.c_str());
for (int i = 1; a[i]; i++) {
unlike[i] = unlike[i-1] + !!(a[i] - b[i]);
for (int j = 0; j < 3; j++) {
counta[i][j] = counta[i-1][j] + (j["ATC"] == a[i]);
countb[i][j] = countb[i-1][j] + (j["ATC"] == b[i]);
}
}
}
int get_distance(int x, int y) {
x++;y++;
for (int i = 0; i < 3; i++)
if (counta[y][i] - counta[x-1][i] != countb[y][i] - countb[x-1][i])
return -1;
return (unlike[y] - unlike[x-1]) - 1;
}
int main(void) {
init("ATACAT", "ACTATA");
printf("%d\n", get_distance(1, 3));
return 0;
}
