제출 #1108453

#제출 시각아이디문제언어결과실행 시간메모리
1108453huyngoDNA 돌연변이 (IOI21_dna)C++17
100 / 100
42 ms7456 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; const int mxN = 1e5 + 5; int n; int c[3][3][mxN]; int encode(char ch) { if (ch == 'A') return 0; if (ch == 'T') return 1; return 2; } void init(std::string a, std::string b) { n = a.size(); for (int i = 0; i < n; ++i) { int x = encode(a[i]); int y = encode(b[i]); c[x][y][i + 1]++; } for (int i = 1; i <= n; ++i) { for (int x = 0; x < 3; ++x) for (int y = 0; y < 3; ++y) c[x][y][i] += c[x][y][i - 1]; } } int get_distance(int l, int r) { ++r; int res = -1; vector<vector<int>> f(3, vector<int>(3)); for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) { f[i][j] = c[i][j][r] - c[i][j][l]; } int x = f[0][1] - f[1][0]; int y = f[0][2] - f[2][0]; int z = f[1][2] - f[2][1]; if ((x == -y && -y == z) || (-x == y && y == -z)) { res = min(f[0][1], f[1][0]) + min(f[0][2], f[2][0]) + min(f[1][2], f[2][1]); x = abs(x); res += x * 2; } return res; }
#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...