제출 #631204

#제출 시각아이디문제언어결과실행 시간메모리
631204qwerasdfzxclDNA 돌연변이 (IOI21_dna)C++17
100 / 100
36 ms7192 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int n, S[100100][9], mp[202]; void init(std::string a, std::string b) { n = a.size(); mp['A'] = 0, mp['C'] = 1, mp['T'] = 2; for (int i=0;i<n;i++){ int cur = mp[a[i]]*3+mp[b[i]]; for (int j=0;j<9;j++) S[i+1][j] = S[i][j]; S[i+1][cur]++; } } int get_distance(int x, int y) { x++, y++; int cur[9], ret = 0; for (int j=0;j<9;j++) cur[j] = S[y][j] - S[x-1][j]; //for (int j=0;j<9;j++) printf("%d ", cur[j]); //printf("\n"); if (cur[0]+cur[1]+cur[2]!=cur[0]+cur[3]+cur[6]) return -1; if (cur[3]+cur[4]+cur[5]!=cur[1]+cur[4]+cur[7]) return -1; if (cur[6]+cur[7]+cur[8]!=cur[2]+cur[5]+cur[8]) return -1; int tmp1 = min(cur[2], cur[6]), tmp2 = min(cur[1], cur[3]), tmp3 = min(cur[5], cur[7]); ret += tmp1+tmp2+tmp3; cur[2] -= tmp1, cur[6] -= tmp1; cur[1] -= tmp2, cur[3] -= tmp2; cur[5] -= tmp3, cur[7] -= tmp3; return ret+cur[1]*2+cur[2]*2; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:12:26: warning: array subscript has type 'char' [-Wchar-subscripts]
   12 |         int cur = mp[a[i]]*3+mp[b[i]];
      |                          ^
dna.cpp:12:37: warning: array subscript has type 'char' [-Wchar-subscripts]
   12 |         int cur = mp[a[i]]*3+mp[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...