제출 #441067

#제출 시각아이디문제언어결과실행 시간메모리
441067lalafaDNA 돌연변이 (IOI21_dna)C++17
71 / 100
1579 ms2396 KiB
#include <string> #include <algorithm> static std::string a_, b_; void init(std::string a, std::string b) { a_ = a; b_ = b; } int get_distance(int x, int y) { int c[3] = {0,0,0}; int cc[3][3]; for (int i = 0; i <9 ; ++i) cc[i/3][i%3] = 0; auto v = [](char c) { return c == 'A' ? 0 : c == 'C' ? 1 : 2; }; for (int i = x; i <= y; ++i) { int v0 = v(a_[i]), v1 = v(b_[i]); ++cc[v0][v1]; ++c[v0]; --c[v1]; } if (c[0] != 0 || c[1] != 0 || c[2] != 0) return -1; int res = 0, mv = 0; for (int v0 = 0; v0 < 2; ++v0) { for (int v1 = v0 + 1; v1 < 3; ++v1) { int vlo = std::min(cc[v0][v1], cc[v1][v0]); int vhi = std::max(cc[v0][v1], cc[v1][v0]); res += vlo; mv = std::max(mv, vhi - vlo); } } return res + 2 * mv; }
#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...