제출 #438909

#제출 시각아이디문제언어결과실행 시간메모리
438909SkyWingDNA 돌연변이 (IOI21_dna)C++17
21 / 100
46 ms2372 KiB
#include "dna.h" #include <iostream> using namespace std; string A, B; void init(std::string a, std::string b) { A = a, B = b; } int get_distance(int x, int y) { int C1[] = {0, 0, 0}, C2[] = {0, 0, 0}, c; for (int i = x; i <= y; i++) { if (A[i] == 'A') C1[0]++; if (A[i] == 'T') C1[1]++; if (A[i] == 'C') C1[2]++; if (B[i] == 'A') C2[0]++; if (B[i] == 'T') C2[1]++; if (B[i] == 'C') C2[2]++; if (A[i] != B[i]) c++; } if (C1[0] != C2[0] || C1[1] != C2[1] || C1[2] != C2[2]) return -1; if (y - x <= 2) { if (y - x == 0) return 0; if (y - x == 1) { if (A[x] == B[x]) return 0; return 1; } if (A[x] == B[x] && A[x + 1] == B[x + 1] && A[y] == B[y]) return 0; if (A[x] == B[x] || A[x + 1] == B[x + 1] || A[y] == B[y]) return 1; return 2; } if (C1[2] == 0 && C2[2] == 0) return c / 2; return 0; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:23:22: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |   if (A[i] != B[i]) c++;
      |                     ~^~
#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...