제출 #677038

#제출 시각아이디문제언어결과실행 시간메모리
677038bene42DNA 돌연변이 (IOI21_dna)C++17
0 / 100
32 ms7020 KiB
#include "dna.h" /* Subtasks 1-3 => only A and T bases */ int A1[100005], T1[100005], C1[100005]; int A2[100005], T2[100005], C2[100005]; int wAT[100005], wTC[100005], wAC[100005]; void init(std::string a, std::string b) { for (int i = 0; i < a.size(); i++){ if (i > 0){ A1[i] = A1[i - 1]; T1[i] = T1[i - 1]; C1[i] = C1[i - 1]; A2[i] = A2[i - 1]; T2[i] = T2[i - 1]; C2[i] = C2[i - 1]; wAT[i] = wAT[i - 1]; wAC[i] = wAC[i - 1]; wTC[i] = wTC[i - 1]; } A1[i] += a[i] == 'A' ? 1 : 0; T1[i] += a[i] == 'T' ? 1 : 0; C1[i] += a[i] == 'C' ? 1 : 0; A2[i] += b[i] == 'A' ? 1 : 0; T2[i] += b[i] == 'T' ? 1 : 0; C2[i] += b[i] == 'C' ? 1 : 0; if (a[i] != b[i]){ if (a[i] == 'A'){ wAT[i] += b[i] == 'T' ? 1 : 0; wAC[i] += b[i] == 'C' ? 1 : 0; } else { if (a[i] == 'T'){ wAT[i] += b[i] == 'A' ? 1 : 0; wTC[i] += b[i] == 'C' ? 1 : 0; } else { wAC[i] += b[i] == 'A' ? 1 : 0; wTC[i] += b[i] == 'T' ? 1 : 0; } } } } } int get_distance(int x, int y) { int dist = 0; int dA, dT, dC; dA = (A1[y] - (x == 0 ? 0 : A1[x - 1])) - (A2[y] - (x == 0 ? 0 : A2[x - 1])); dT = (T1[y] - (x == 0 ? 0 : T1[x - 1])) - (T2[y] - (x == 0 ? 0 : C2[x - 1])); dC = (C1[y] - (x == 0 ? 0 : C1[x - 1])) - (C2[y] - (x == 0 ? 0 : C2[x - 1])); if (dA != 0 || dT != 0 || dC != 0){ return -1; } // If there's only A and T bases if (C1[y] == 0 && C2[y] == 0){ return (wAT[y] - (x == 0 ? 0 : wAT[x - 1])) / 2; } return dist; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:15:23: 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...