제출 #1106617

#제출 시각아이디문제언어결과실행 시간메모리
1106617kheiraDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" using namespace std; vector<int> A_a , C_a , T_a ; vector<int> A_b , C_b , T_b; void init(string a, astring b) { int n = a.size(); A_a = C_a = T_a = vector<int>(n+1 , 0) ; A_b = C_b = T_b = vector<int>(n+1 , 0) ; for(int i = 1 ; i <= n ; ++i){ A_a[i] = A_a[i - 1] + (a[i - 1] == 'A'); C_a[i] = C_a[i - 1] + (a[i - 1] == 'C'); T_a[i] = T_a[i - 1] + (a[i - 1] == 'T'); A_b[i] = A_b[i - 1] + (b[i - 1] == 'A'); C_b[i] = C_b[i - 1] + (b[i - 1] == 'C'); T_b[i] = T_b[i - 1] + (b[i - 1] == 'T'); } } int get_distance(int x, int y) { int a_count_A = A_a[y + 1] - A_a[x]; int a_count_C = C_a[y + 1] - C_a[x]; int a_count_T = T_a[y + 1] - T_a[x]; int b_count_A = A_b[y + 1] - A_b[x]; int b_count_C = C_b[y + 1] - C_b[x]; int b_count_T = T_b[y + 1] - T_b[x]; if (a_count_A != b_count_A || a_count_C != b_count_C || a_count_T != b_count_T) { return -1; } int makanch_AC = 0, makanch_AT = 0, makanch_CT = 0; return makanch_AC + makanch_AT + makanch_CT; return 0; }

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

dna.cpp:3:1: error: 'vector' does not name a type
    3 | vector<int> A_a , C_a , T_a ;
      | ^~~~~~
dna.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int> A_b , C_b , T_b;
      | ^~~~~~
dna.cpp:5:21: error: 'astring' has not been declared
    5 | void init(string a, astring b) {
      |                     ^~~~~~~
dna.cpp: In function 'void init(std::string, int)':
dna.cpp:7:5: error: 'A_a' was not declared in this scope
    7 |     A_a = C_a = T_a = vector<int>(n+1 , 0) ;
      |     ^~~
dna.cpp:7:11: error: 'C_a' was not declared in this scope
    7 |     A_a = C_a = T_a = vector<int>(n+1 , 0) ;
      |           ^~~
dna.cpp:7:17: error: 'T_a' was not declared in this scope
    7 |     A_a = C_a = T_a = vector<int>(n+1 , 0) ;
      |                 ^~~
dna.cpp:7:23: error: 'vector' was not declared in this scope
    7 |     A_a = C_a = T_a = vector<int>(n+1 , 0) ;
      |                       ^~~~~~
dna.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "dna.h"
  +++ |+#include <vector>
    2 | using namespace std;
dna.cpp:7:30: error: expected primary-expression before 'int'
    7 |     A_a = C_a = T_a = vector<int>(n+1 , 0) ;
      |                              ^~~
dna.cpp:8:5: error: 'A_b' was not declared in this scope
    8 |     A_b = C_b = T_b = vector<int>(n+1 , 0) ;
      |     ^~~
dna.cpp:8:11: error: 'C_b' was not declared in this scope
    8 |     A_b = C_b = T_b = vector<int>(n+1 , 0) ;
      |           ^~~
dna.cpp:8:17: error: 'T_b' was not declared in this scope
    8 |     A_b = C_b = T_b = vector<int>(n+1 , 0) ;
      |                 ^~~
dna.cpp:8:30: error: expected primary-expression before 'int'
    8 |     A_b = C_b = T_b = vector<int>(n+1 , 0) ;
      |                              ^~~
dna.cpp:14:33: error: invalid types 'int[int]' for array subscript
   14 |         A_b[i] = A_b[i - 1] + (b[i - 1] == 'A');
      |                                 ^
dna.cpp:15:33: error: invalid types 'int[int]' for array subscript
   15 |         C_b[i] = C_b[i - 1] + (b[i - 1] == 'C');
      |                                 ^
dna.cpp:16:33: error: invalid types 'int[int]' for array subscript
   16 |         T_b[i] = T_b[i - 1] + (b[i - 1] == 'T');
      |                                 ^
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:21:21: error: 'A_a' was not declared in this scope
   21 |     int a_count_A = A_a[y + 1] - A_a[x];
      |                     ^~~
dna.cpp:22:21: error: 'C_a' was not declared in this scope
   22 |     int a_count_C = C_a[y + 1] - C_a[x];
      |                     ^~~
dna.cpp:23:21: error: 'T_a' was not declared in this scope
   23 |     int a_count_T = T_a[y + 1] - T_a[x];
      |                     ^~~
dna.cpp:24:21: error: 'A_b' was not declared in this scope
   24 |     int b_count_A = A_b[y + 1] - A_b[x];
      |                     ^~~
dna.cpp:25:21: error: 'C_b' was not declared in this scope
   25 |     int b_count_C = C_b[y + 1] - C_b[x];
      |                     ^~~
dna.cpp:26:21: error: 'T_b' was not declared in this scope
   26 |     int b_count_T = T_b[y + 1] - T_b[x];
      |                     ^~~