제출 #440080

#제출 시각아이디문제언어결과실행 시간메모리
440080abekerDNA 돌연변이 (IOI21_dna)C++17
100 / 100
77 ms7412 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; const int MAXN = 1e5 + 5; const char DNA[] = "ACT"; int cnt[MAXN][3][3]; int get_id(char c) { return strchr(DNA, c) - DNA; } void init(string a, string b) { for (int i = 0; i < a.size(); i++) { if (i) memcpy(cnt[i], cnt[i - 1], sizeof cnt[i]); cnt[i][get_id(a[i])][get_id(b[i])]++; } } int get_cnt(int x, int y, int i, int j) { return cnt[y][i][j] - (x ? cnt[x - 1][i][j] : 0); } int get_distance(int x, int y) { int res = 0; vector <int> row(3), col(3); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { int p = get_cnt(x, y, i, j); row[i] += p; col[j] += p; if (i >= j) continue; int q = get_cnt(x, y, j, i); if (p < q) swap(p, q); res += 2 * p + q; } for (int i = 0; i < 3; i++) if (row[i] != col[i]) return -1; return (res + 2) / 3; }

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

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