제출 #558555

#제출 시각아이디문제언어결과실행 시간메모리
558555pawnedMutating DNA (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" 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]++; } return; } 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]); }

컴파일 시 표준 에러 (stderr) 메시지

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:40:7: error: 'pfs1' was not declared in this scope
   40 |   if (pfs1[y][i] - pfs[x - 1][i] != pfs2[y][i] - pfs2[x - 1][i])
      |       ^~~~
dna.cpp:40:20: error: 'pfs' was not declared in this scope
   40 |   if (pfs1[y][i] - pfs[x - 1][i] != pfs2[y][i] - pfs2[x - 1][i])
      |                    ^~~
dna.cpp:40:37: error: 'pfs2' was not declared in this scope
   40 |   if (pfs1[y][i] - pfs[x - 1][i] != pfs2[y][i] - pfs2[x - 1][i])
      |                                     ^~~~
dna.cpp:46:11: error: 'pfs' was not declared in this scope
   46 |   return (pfs[y] - pfs[x - 1]);
      |           ^~~