제출 #448498

#제출 시각아이디문제언어결과실행 시간메모리
448498VladithurDNA 돌연변이 (IOI21_dna)C++17
100 / 100
54 ms7408 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; int n, p[100001][3][3]; void init(std::string a, std::string b) { n = a.size(); map<char, int> tm; tm['A'] = 0; tm['T'] = 1; tm['C'] = 2; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) p[i + 1][j][k] = p[i][j][k]; } int j = tm[a[i]], k = tm[b[i]]; p[i + 1][j][k]++; } } int get_distance(int x, int y) { y++; vector<int> ta(3); int ans = y - x; for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { int v = p[y][j][k] - p[x][j][k]; ta[j] += v; ta[k] -= v; if (j == k) ans -= v; } } for (int tx: ta) { if (tx != 0) { return -1; } } int ttx = n; for (int j = 0; j < 3; j++) { for (int k = j + 1; k < 3; k++) { int tx = p[y][j][k] - p[x][j][k], ty = p[y][k][j] - p[x][k][j]; ans -= min(tx, ty); ttx = min(ttx, max(tx, ty) - min(tx, ty)); } } return ans - ttx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...