제출 #607319

#제출 시각아이디문제언어결과실행 시간메모리
607319wiktorlewDNA 돌연변이 (IOI21_dna)C++17
100 / 100
43 ms8600 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int ile[N][3][2], line[N][3][2]; int tsf(char c){ if(c=='A') return 0; if(c=='C') return 1; if(c=='T') return 2; } void init(string a, string b){ for(int i=0;i<a.length();i++){ ile[i+1][tsf(a[i])][0]++; ile[i+1][tsf(b[i])][1]++; if(a[i]=='A'&&b[i]=='C') line[i+1][0][0]++; if(a[i]=='A'&&b[i]=='T')line[i+1][1][0]++; if(a[i]=='C'&&b[i]=='T')line[i+1][2][0]++; if(a[i]=='C'&&b[i]=='A') line[i+1][0][1]++; if(a[i]=='T'&&b[i]=='A')line[i+1][1][1]++; if(a[i]=='T'&&b[i]=='C')line[i+1][2][1]++; for(int j=0;j<=2;j++){ ile[i+1][j][0]+=ile[i][j][0]; ile[i+1][j][1]+=ile[i][j][1]; line[i+1][j][0]+=line[i][j][0]; line[i+1][j][1]+=line[i][j][1]; } } } int get_distance(int x, int y){ x++; y++; if(ile[y][0][0]-ile[x-1][0][0]!=ile[y][0][1]-ile[x-1][0][1]){ return -1; } if(ile[y][1][0]-ile[x-1][1][0]!=ile[y][1][1]-ile[x-1][1][1]){ return -1; } if(ile[y][2][0]-ile[x-1][2][0]!=ile[y][2][1]-ile[x-1][2][1]){ return -1; } int wynik=0, err=0; for(int i=0;i<=2;i++){ int pom1 = line[y][i][0]-line[x-1][i][0]; int pom2 = line[y][i][1]-line[x-1][i][1]; wynik+=(min(pom1, pom2)); err+=abs(pom1-pom2); } wynik+=(err/3)*2; return wynik; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0;i<a.length();i++){
      |              ~^~~~~~~~~~~
dna.cpp: In function 'int tsf(char)':
dna.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]
    9 | }
      | ^
#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...