제출 #621424

#제출 시각아이디문제언어결과실행 시간메모리
621424grubodupiecDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <cmath> using namespace std; const int MAXN = (10^5)+7; int lista[MAXN][MAXN]; void init(string a, string b, int n, int lista1[MAXN][MAXN]) { int c1=0;int c2=0;int c3=0;int c4=0;int c5=0;int c6=0; for(int i=0;i<n;i++) { if(a[i]=='T'&&b[i]=='A') c1++; if(a[i]=='A'&&b[i]=='T') c2++; if(a[i]=='C'&&b[i]=='A') c3++; if(a[i]=='A'&&b[i]=='C') c4++; if(a[i]=='T'&&b[i]=='C') c5++; if(a[i]=='C'&&b[i]=='T') c6++; lista1[1][i]=c1; lista1[2][i]=c2; lista1[3][i]=c3; lista1[4][i]=c4; lista1[5][i]=c5; lista1[6][i]=c6; } }; int get_distance(int x, int y,int lista[MAXN][MAXN]) { int m=0; int TA=lista[1][y]-lista[1][x-1]; int AT=lista[2][y]-lista[2][x-1]; int CA=lista[3][y]-lista[3][x-1]; int AC=lista[4][y]-lista[4][x-1]; int TC=lista[5][y]-lista[5][x-1]; int CT=lista[6][y]-lista[6][x-1]; int tat, cac, tct; if (TA < AT) { m += TA; tat = AT - TA; } else { m += AT; tat = TA - AT; } if (CA < AC) { m += CA; cac = AC - CA; } else { m += AC; cac = CA - AC; } if (TC < CT) { m += TC; tct = CT - TC; } else { m += CT; tct = TC - CT; } m+=2*tat; if(!(tat==cac&&cac==tct)) return -1; else return m; } int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n,h; string f; cin>>n>>h; string a,b; cin>>a>>b; init(a,b,n,lista); for(int i=0;i<h;i++) { int x;int y; cin>>x>>y; cout<<get_distance(x,y,lista)<<'\n'; } return 0; }

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

/usr/bin/ld: /tmp/ccaa5jSv.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccGhysxx.o:dna.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccaa5jSv.o: in function `main':
grader.cpp:(.text.startup+0x366): undefined reference to `init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x39d): undefined reference to `get_distance(int, int)'
collect2: error: ld returned 1 exit status