제출 #494040

#제출 시각아이디문제언어결과실행 시간메모리
494040TsiannisDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "dna.h" using namespace std; typedef long long ll; #define maxn 100005 ll a1[maxn],c1[maxn],t1[maxn],a2[maxn],c2[maxn],t2[maxn],diff[maxn]; void init(string a,string b) { for (int i=0;i<a.size();i++) { a1[i+1]=a1[i]; c1[i+1]=c1[i]; t1[i+1]=t1[i]; a2[i+1]=a2[i]; c2[i+1]=c2[i]; t2[i+1]=t2[i]; diff[i+1]=diff[i]; if (a[i]=='A') a1[i+1]=a1[i]+1; else if (a[i]=='C') c1[i+1]=c1[i]+1; else t1[i+1]=t1[i]+1; if (b[i]=='A') a2[i+1]=a2[i]+1; else if (b[i]=='C') c2[i+1]=c2[i]+1; else t2[i+1]=t2[i]+1; if (a[i]!=b[i]) {diff[i+1]=diff[i]+1;} } } int get_distance(int x,int y) { int pla1=a1[y+1]-a1[x]; int plc1=c1[y+1]-c1[x]; int plt1=t1[y+1]-t1[x]; int pla2=a2[y+1]-a2[x]; int plc2=c2[y+1]-c2[x]; int plt2=t2[y+1]-t2[x]; int d=diff[y+1]-diff[x]; if (pla1!=pla2||plc1!=plc2||plt1!=plt2) return -1; else return (d/2+d%2); } int main() { int n,q; cin>>n>>q; string s1,s2; cin>>s1>>s2; init(s1,s2); while(q--) { int x,y; cin>>x>>y; cout<<get_distance(x,y)<<endl; } return 0; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int i=0;i<a.size();i++)
      |                  ~^~~~~~~~~
/usr/bin/ld: /tmp/cc8HqqGT.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccU7GkcX.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status