제출 #483598

#제출 시각아이디문제언어결과실행 시간메모리
483598ponytailDNA 돌연변이 (IOI21_dna)C++17
56 / 100
46 ms4876 KiB
#include "dna.h" #include <string> #include <bits/stdc++.h> using namespace std; void init(std::string a, std::string b); int get_distance(int x, int y); int ps[6][100000]; void init(std::string a, std::string b) { string patt[6] = {"CA", "AC", "TA", "AT", "CT", "TC"}; for(int i=0; i<a.size(); i++) { for(int j=0; j<6; j++) { string now; now += a[i]; now += b[i]; ps[j][i] = (i==0 ? 0 : ps[j][i-1]) + (now == patt[j]); } } } int get_distance(int x, int y) { int res[6]; for(int i=0; i<6; i++) res[i] = ps[i][y] - (x==0 ? 0 : ps[i][x-1]); if(res[0] + res[4] != res[1] + res[5]) return -1; if(res[1] + res[3] != res[0] + res[2]) return -1; if(res[2] + res[5] != res[3] + res[4]) return -1; int m1 = min(res[0], res[1]), m2 = min(res[2], res[3]), m3 = min(res[4], res[5]); int ans = m1 + m2 + m3; res[0] -= m1; res[1] -= m1; res[2] -= m2; res[3] -= m2; res[4] -= m3; res[5] -= m3; int sum = 0; for(int i=0; i<6; i++) sum += res[i]; ans += max(0, sum - 1); return ans; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     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...