제출 #669805

#제출 시각아이디문제언어결과실행 시간메모리
669805MarszpaceDNA 돌연변이 (IOI21_dna)C++17
43 / 100
1585 ms3780 KiB
#include<bits/stdc++.h> using namespace std; vector<bool> diff; string aGlobal,bGlobal; void init(string a, string b){ for(int i=0;i<a.size();i++){ diff.push_back(!(a[i]==b[i])); } aGlobal=a; bGlobal=b; } int get_distance(int x, int y){ int a[3]={},b[3]={}; for(int i=x;i<=y;i++){ if(aGlobal[i]=='A'){a[0]++;} else if(aGlobal[i]=='T'){a[1]++;} else if(aGlobal[i]=='C'){a[2]++;} if(bGlobal[i]=='A'){b[0]++;} else if(bGlobal[i]=='T'){b[1]++;} else if(bGlobal[i]=='C'){b[2]++;} } if(a[0]!=b[0]||a[1]!=b[1]||a[2]!=b[2]){return -1;} int res=0; for(int i=x;i<=y;i++){ if(diff[i]){res++;} } return (res+1)/2; } /* int main(){ init("ATACAT", "ACTATA"); cout << aGlobal << endl << bGlobal << endl; cout << get_distance(1, 3) << " " << get_distance(4, 5) << " " << get_distance(3, 5); } */

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:6:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...