Submission #441077

#TimeUsernameProblemLanguageResultExecution timeMemory
441077lalafaMutating DNA (IOI21_dna)C++17
0 / 100
43 ms5608 KiB
#include <string> #include <algorithm> std::vector<int>ccc; void init(std::string a, std::string b) { auto v = [](char c) { return c == 'A' ? 0 : c == 'C' ? 1 : 2; }; ccc.resize(a.size() * 9 + 10, 0); for (int i = 0; i < a.size(); ++i) { for(int j = 0; j < 9; ++j) ccc[i*9 + j + 9] = ccc[i*9 + j]; int v9 = v(a[i]) * 3 + v(b[i]); ccc[i*9 +v9 + 9] = ccc[i*9 + v9]; } } int get_distance(int x, int y) { int c[3] = {0,0,0}; int cc[3][3]; for (int i = 0; i <9 ; ++i) { int v = ccc[y*9 + 9 + i] - ccc[x*9 + i]; cc[i/3][i%3] = v; c[i/3] += v; c[i%3] -= v; } 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; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:9:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |   for (int i = 0; i < a.size(); ++i) {
      |                   ~~^~~~~~~~~~
#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...