제출 #484439

#제출 시각아이디문제언어결과실행 시간메모리
484439Spade1DNA 돌연변이 (IOI21_dna)C++17
100 / 100
35 ms6212 KiB
#include <bits/stdc++.h> #include "dna.h" #define ll long long #define pii pair<int, int> #define st first #define nd second #define pb push_back using namespace std; int p[100010][6]; void init(string a, string b) { for (int i = 1; i <= a.size(); ++i) { if (a[i - 1] == 'A' && b[i - 1] == 'C') p[i][0]++; if (a[i - 1] == 'A' && b[i - 1] == 'T') p[i][1]++; if (a[i - 1] == 'C' && b[i - 1] == 'A') p[i][2]++; if (a[i - 1] == 'C' && b[i - 1] == 'T') p[i][3]++; if (a[i - 1] == 'T' && b[i - 1] == 'A') p[i][4]++; if (a[i - 1] == 'T' && b[i - 1] == 'C') p[i][5]++; for (int j = 0; j < 6; ++j) p[i][j] += p[i - 1][j]; } } int get_distance(int x, int y) { ++x, ++y; int tmp[6]; for (int i = 0; i < 6; ++i) { tmp[i] = p[y][i] - p[x - 1][i]; } int A1 = tmp[0] + tmp[1], A2 = tmp[2] + tmp[4]; int C1 = tmp[2] + tmp[3], C2 = tmp[0] + tmp[5]; int T1 = tmp[4] + tmp[5], T2 = tmp[1] + tmp[3]; if (A1 != A2 || C1 != C2 || T1 != T2) return -1; int ans1 = 0; for (int i = 0; i < 6; ++i) ans1 += tmp[i]; int ans2 = min(tmp[0], tmp[2]) + min(tmp[1], tmp[4]) + min(tmp[3], tmp[5]); ans1 -= 2*ans2; ans1 = ans1/3*2; return ans1 + ans2; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:13:23: 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 = 1; 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...