Submission #558554

#TimeUsernameProblemLanguageResultExecution timeMemory
558554pawnedMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
void init(std::string a, std::string b) { int N = a.size(); int pfs1[N + 1][3]; pfs1[0][0] = 0; pfs1[0][1] = 0; pfs1[0][2] = 0; int pfs2[N + 1][3]; pfs2[0][0] = 0; pfs2[0][1] = 0; pfs2[0][2] = 0; for (int i = 1; i <= N; i++) { if (a[i - 1] == 'A') pfs1[i][0] = pfs1[i - 1][0] + 1; if (a[i - 1] == 'T') pfs1[i][1] = pfs1[i - 1][1] + 1; if (a[i - 1] == 'C') pfs1[i][2] = pfs1[i - 1][2] + 1; if (b[i - 1] == 'A') pfs2[i][0] = pfs2[i - 1][0] + 1; if (b[i - 1] == 'T') pfs2[i][1] = pfs2[i - 1][1] + 1; if (b[i - 1] == 'C') pfs2[i][2] = pfs2[i - 1][2] + 1; } int pfs[N + 1]; pfs[0] = 0; for (int i = 1; i <= N; i++) { pfs[i] = pfs[i - 1]; if (a[i - 1] != b[i - 1]) pfs[i]++; } } int get_distance(int x, int y) { bool works = true; for (int i = 0; i < 3; i++) { if (pfs1[y][i] - pfs[x - 1][i] != pfs2[y][i] - pfs2[x - 1][i]) works = false; } if (!works) return -1; else return (pfs[y] - pfs[x - 1]); }

Compilation message (stderr)

dna.cpp:1:6: error: variable or field 'init' declared void
    1 | void init(std::string a, std::string b) {
      |      ^~~~
dna.cpp:1:16: error: 'string' is not a member of 'std'
    1 | void init(std::string a, std::string b) {
      |                ^~~~~~
dna.cpp:1:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
  +++ |+#include <string>
    1 | void init(std::string a, std::string b) {
dna.cpp:1:31: error: 'string' is not a member of 'std'
    1 | void init(std::string a, std::string b) {
      |                               ^~~~~~
dna.cpp:1:31: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:37:7: error: 'pfs1' was not declared in this scope
   37 |   if (pfs1[y][i] - pfs[x - 1][i] != pfs2[y][i] - pfs2[x - 1][i])
      |       ^~~~
dna.cpp:37:20: error: 'pfs' was not declared in this scope
   37 |   if (pfs1[y][i] - pfs[x - 1][i] != pfs2[y][i] - pfs2[x - 1][i])
      |                    ^~~
dna.cpp:37:37: error: 'pfs2' was not declared in this scope
   37 |   if (pfs1[y][i] - pfs[x - 1][i] != pfs2[y][i] - pfs2[x - 1][i])
      |                                     ^~~~
dna.cpp:43:11: error: 'pfs' was not declared in this scope
   43 |   return (pfs[y] - pfs[x - 1]);
      |           ^~~