제출 #1085123

#제출 시각아이디문제언어결과실행 시간메모리
1085123acoatoitgsDNA 돌연변이 (IOI21_dna)C++17
56 / 100
28 ms6248 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; int N; vector<array<int, 3>> A, B; int c(char a) { return (a == 'A' ? 0 : (a == 'T' ? 1 : 2)); } void init(std::string a, std::string b) { N = a.size(); A.resize(N, {0, 0, 0}); B.resize(N, {0, 0, 0}); if (a[0] != b[0]) { A[0][c(a[0])]++; B[0][c(b[0])]++; } for (int i = 1; i < N; i++) { A[i][0] = A[i - 1][0]; A[i][1] = A[i - 1][1]; A[i][2] = A[i - 1][2]; B[i][0] = B[i - 1][0]; B[i][1] = B[i - 1][1]; B[i][2] = B[i - 1][2]; if (a[i] != b[i]) { A[i][c(a[i])]++; B[i][c(b[i])]++; } } } int get_distance(int x, int y) { array<int, 3> dA = A[y], dB = B[y]; if (x != 0) { dA[0] -= A[x - 1][0]; dA[1] -= A[x - 1][1]; dA[2] -= A[x - 1][2]; dB[0] -= B[x - 1][0]; dB[1] -= B[x - 1][1]; dB[2] -= B[x - 1][2]; } if (dA == dB) { return (1 + dA[0] + dA[1] + dA[2]) / 2; } return -1; }
#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...