Submission #440794

#TimeUsernameProblemLanguageResultExecution timeMemory
440794lalafaMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
static string a_, b_; void init(string a, string b) { a_ = a; b_ = b; } int get_distance(int x, int y) { int[3] c = {0,0,0}; int[3][3] cc; 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:1:8: error: 'string' does not name a type
    1 | static string a_, b_;
      |        ^~~~~~
dna.cpp:2:6: error: variable or field 'init' declared void
    2 | void init(string a, string b) {
      |      ^~~~
dna.cpp:2:11: error: 'string' was not declared in this scope
    2 | void init(string a, string b) {
      |           ^~~~~~
dna.cpp:2:21: error: 'string' was not declared in this scope
    2 | void init(string a, string b) {
      |                     ^~~~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:7:7: error: expected identifier before numeric constant
    7 |   int[3] c = {0,0,0};
      |       ^
dna.cpp:7:7: error: expected ']' before numeric constant
    7 |   int[3] c = {0,0,0};
      |       ^
      |       ]
dna.cpp:7:6: error: structured binding declaration cannot have type 'int'
    7 |   int[3] c = {0,0,0};
      |      ^
dna.cpp:7:6: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
dna.cpp:7:6: error: empty structured binding declaration
dna.cpp:7:10: error: expected initializer before 'c'
    7 |   int[3] c = {0,0,0};
      |          ^
dna.cpp:8:7: error: expected identifier before numeric constant
    8 |   int[3][3] cc;
      |       ^
dna.cpp:8:7: error: expected ']' before numeric constant
    8 |   int[3][3] cc;
      |       ^
      |       ]
dna.cpp:8:6: error: structured binding declaration cannot have type 'int'
    8 |   int[3][3] cc;
      |      ^
dna.cpp:8:6: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
dna.cpp:8:6: error: empty structured binding declaration
dna.cpp:8:9: error: expected initializer before '[' token
    8 |   int[3][3] cc;
      |         ^
dna.cpp:9:31: error: 'cc' was not declared in this scope
    9 |   for (int i = 0; i <9 ; ++i) cc[i/3][i%3] = 0;
      |                               ^~
dna.cpp:12:16: error: 'a_' was not declared in this scope
   12 |     int v0 = v(a_[i]), v1 = v(b_[i]);
      |                ^~
dna.cpp:13:7: error: 'cc' was not declared in this scope
   13 |     ++cc[v0][v1];
      |       ^~
dna.cpp:13:14: error: 'v1' was not declared in this scope; did you mean 'v0'?
   13 |     ++cc[v0][v1];
      |              ^~
      |              v0
dna.cpp:14:7: error: 'c' was not declared in this scope
   14 |     ++c[v0];
      |       ^
dna.cpp:17:7: error: 'c' was not declared in this scope
   17 |   if (c[0] != 0 || c[1] != 0 || c[2] != 0) return -1;
      |       ^
dna.cpp:21:22: error: 'min' is not a member of 'std'
   21 |       int vl0 = std::min(cc[v0][v1], cc[v1][v0]);
      |                      ^~~
dna.cpp:21:26: error: 'cc' was not declared in this scope
   21 |       int vl0 = std::min(cc[v0][v1], cc[v1][v0]);
      |                          ^~
dna.cpp:22:22: error: 'max' is not a member of 'std'
   22 |       int vhi = std::max(cc[v0][v1], cc[v1][v0]);
      |                      ^~~
dna.cpp:24:17: error: 'max' is not a member of 'std'
   24 |       mv = std::max(mv, vhi - vlo);
      |                 ^~~
dna.cpp:24:31: error: 'vlo' was not declared in this scope; did you mean 'vl0'?
   24 |       mv = std::max(mv, vhi - vlo);
      |                               ^~~
      |                               vl0
dna.cpp:7:6: warning: unused structured binding declaration [-Wunused-variable]
    7 |   int[3] c = {0,0,0};
      |      ^
dna.cpp:8:6: warning: unused structured binding declaration [-Wunused-variable]
    8 |   int[3][3] cc;
      |      ^