제출 #691717

#제출 시각아이디문제언어결과실행 시간메모리
691717ismayilDNA 돌연변이 (IOI21_dna)C++17
0 / 100
48 ms7284 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int MAX = 1e5 + 5; int dp[MAX][3][3], cnt[MAX][3]; int n; void init(string a, string b){ map<char, char> m = {{'A', 0}, {'T', 1}, {'C', 2}}; n = a.size(); for (int i = 0; i < n; i++) { a[i] = m[a[i]]; b[i] = m[b[i]]; } if(a[0] != b[0]) dp[0][a[0]][b[0]]++; for (int i = 1; i < n; i++) { for (int j = 0; j < 3; j++){ for (int k = 0; k < 3; k++) dp[i][j][k] = dp[i - 1][j][k]; cnt[i][j] = cnt[i - 1][j]; } if(a[i] != b[i]) dp[i][a[i]][b[i]]++; cnt[i][a[i]]++; cnt[i][b[i]]--; } } int get_distance(int x, int y){ if(cnt[y][0] - cnt[x - 1][0] != 0) return -1; if(cnt[y][1] - cnt[x - 1][1] != 0) return -1; if(cnt[y][2] - cnt[x - 1][2] != 0) return -1; int c[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { c[i][j] = dp[y][i][j]; if(x != 0) c[i][j] -= dp[x - 1][i][j]; } } int ans = 0, s = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { int a = min(c[i][j], c[j][i]); ans += a; c[i][j] -= a; c[j][i] -= a; s += c[i][j]; } } ans += s / 3 * 2; return ans; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:16:32: warning: array subscript has type 'char' [-Wchar-subscripts]
   16 |     if(a[0] != b[0]) dp[0][a[0]][b[0]]++;
      |                                ^
dna.cpp:16:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   16 |     if(a[0] != b[0]) dp[0][a[0]][b[0]]++;
      |                                      ^
dna.cpp:24:36: warning: array subscript has type 'char' [-Wchar-subscripts]
   24 |         if(a[i] != b[i]) dp[i][a[i]][b[i]]++;
      |                                    ^
dna.cpp:24:42: warning: array subscript has type 'char' [-Wchar-subscripts]
   24 |         if(a[i] != b[i]) dp[i][a[i]][b[i]]++;
      |                                          ^
dna.cpp:25:20: warning: array subscript has type 'char' [-Wchar-subscripts]
   25 |         cnt[i][a[i]]++;
      |                    ^
dna.cpp:26:20: warning: array subscript has type 'char' [-Wchar-subscripts]
   26 |         cnt[i][b[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...