Submission #440954

#TimeUsernameProblemLanguageResultExecution timeMemory
440954lalafaMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 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 vl0 = std::min(cc[v0][v1], cc[v1][v0]); int vhi = std::max(cc[v0][v1], cc[v1][v0]); res += vl0; mv = std::max(mv, vhi - vlo); } } return res + 2 * mv; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:27:31: error: 'vlo' was not declared in this scope; did you mean 'vl0'?
   27 |       mv = std::max(mv, vhi - vlo);
      |                               ^~~
      |                               vl0