제출 #777345

#제출 시각아이디문제언어결과실행 시간메모리
777345Trisanu_DasDNA 돌연변이 (IOI21_dna)C++17
100 / 100
41 ms7400 KiB
#include <bits/stdc++.h> using namespace std; int pref[100005][3][3]; map<char, int> mp; void init(string a, string b){ mp['A'] = 0; mp['C'] = 1; mp['T'] = 2; for(int i = 1; i <= a.size(); i++) for(int j = 0; j < 3; j++) for(int k = 0; k < 3; k++) pref[i][j][k] = pref[i - 1][j][k] + (mp[a[i - 1]] == j && mp[b[i - 1]] == k); } int get_distance(int x, int y){ int actual = 0, add = 0; for(int i = 0; i < 3; i++){ int j = (i + 1) % 3; int m = pref[y + 1][i][j] - pref[x][i][j], n = pref[y + 1][j][i] - pref[x][j][i]; if(i == 0) add = m - n; else if(m - n != add) return -1; actual += min(m, n); } return actual + abs(add) * 2; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:9:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i = 1; i <= a.size(); i++) for(int j = 0; j < 3; j++) for(int k = 0; k < 3; k++) pref[i][j][k] = pref[i - 1][j][k] + (mp[a[i - 1]] == j && mp[b[i - 1]] == k);
      |                    ~~^~~~~~~~~~~
#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...