제출 #483595

#제출 시각아이디문제언어결과실행 시간메모리
483595ponytailDNA 돌연변이 (IOI21_dna)C++17
0 / 100
36 ms4480 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 ans = min(res[0], res[1]) + min(res[2], res[3]) + min(res[4], res[5]); res[0] -= min(res[0], res[1]); res[1] -= min(res[0], res[1]); res[2] -= min(res[2], res[3]); res[3] -= min(res[2], res[3]); res[4] -= min(res[4], res[5]); res[5] -= min(res[4], res[5]); for(int i=0; i<6; i++) ans += res[i]; ans--; 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...