제출 #441336

#제출 시각아이디문제언어결과실행 시간메모리
441336SirCovidThe19thDNA 돌연변이 (IOI21_dna)C++17
100 / 100
52 ms6592 KiB
#include <bits/stdc++.h> using namespace std; int pre[100005][3][3], mp[256]; 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++) pre[i][j][k] = pre[i-1][j][k]+(mp[a[i-1]] == j and mp[b[i-1]] == k); } int get_distance(int a, int b){ int own = 0, share = 0; for (int i = 0; i < 3; i++){ int j = (i+1)%3; int cnt1 = pre[b+1][i][j]-pre[a][i][j]; int cnt2 = pre[b+1][j][i]-pre[a][j][i]; if (i == 0) share = cnt1-cnt2; else if (cnt1-cnt2 != share) return -1; own += min(cnt1, cnt2); }return own+(abs(share)*2); }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:8:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 1; i <= a.size(); i++)
      |                     ~~^~~~~~~~~~~
dna.cpp:11:57: warning: array subscript has type 'char' [-Wchar-subscripts]
   11 |                 pre[i][j][k] = pre[i-1][j][k]+(mp[a[i-1]] == j and mp[b[i-1]] == k);
      |                                                         ^
dna.cpp:11:77: warning: array subscript has type 'char' [-Wchar-subscripts]
   11 |                 pre[i][j][k] = pre[i-1][j][k]+(mp[a[i-1]] == j and 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...