제출 #858243

#제출 시각아이디문제언어결과실행 시간메모리
858243lentibearDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include <string> #include <vector> using namespace std; void init(std::string a, std::string b); int get_distance(int x, int y); vector<int> ct[6]; void init(std::string a, std::string b){ int n=min(a.size(),b.size()); for(int j=0; j<6; j++) ct[j]= vector<int> (n); for(int i=0; i<n; i++) { if(i>0) for(int j=0; j<6; j++) ct[j][i]=ct[j][i-1]; else for(int j=0; j<6; j++) ct[j][i]=0; if(a[i]=='A'){ if(b[i]=='T') ct[0][i]++; else if (b[i]=='C') ct[1][i]++; } if(a[i]=='T'){ if(b[i]=='A') ct[2][i]++; else if (b[i]=='C') ct[3][i]++; } if(a[i]=='C'){ if(b[i]=='A') ct[4][i]++; else if (b[i]=='T') ct[5][i]++; } } int get_distance(int x, int y){ int nct[6]; for(int j=0; j<6; j++) nct[j]=ct[j][y]; if(x>0) for(int j=0; j<6; j++) nct[j]-=ct[j][x-1]; if(nct[0]+nct[1]==nct[2]+nct[4] && nct[2]+nct[3]==nct[0]+nct[5]){ return(min(nct[0], nct[2])+min(nct[1],nct[4])+min(nct[3],nct[5])+max(nct[0]-nct[2],0)*2+max(nct[1]-nct[4],0)*2); } return(-1); }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:29:31: error: a function-definition is not allowed here before '{' token
   29 | int get_distance(int x, int y){
      |                               ^
dna.cpp:37:1: error: expected '}' at end of input
   37 | }
      | ^
dna.cpp:9:40: note: to match this '{'
    9 | void init(std::string a, std::string b){
      |                                        ^