제출 #1081751

#제출 시각아이디문제언어결과실행 시간메모리
1081751raphael_heuchlDNA 돌연변이 (IOI21_dna)C++17
100 / 100
73 ms6608 KiB
#include "dna.h" #include <iostream> #include <map> #include <vector> int N; std::vector<int> v[6]; std::map<std::string, int> mp = {{"AT", 0}, {"TA", 1}, {"AC", 2}, {"TC", 3}, {"CA", 4}, {"CT", 5}}; std::string A, B; void init(std::string a, std::string b) { A = a; B = b; N = a.size(); for (int i = 0; i < 6; ++i) v[i].resize(N + 1); for (int i = 0; i < N; ++i) for (char j : (std::string)"ACT") for (char k : (std::string)"ACT") { if (j == k) continue; int curr = mp[(std::string)"" + j + k]; v[curr][i + 1] = v[curr][i] + (a[i] == j && b[i] == k); } } int get_distance(int x, int y) { int AT = v[0][y + 1] - v[0][x]; int TA = v[1][y + 1] - v[1][x]; int AC = v[2][y + 1] - v[2][x]; int TC = v[3][y + 1] - v[3][x]; int CA = v[4][y + 1] - v[4][x]; int CT = v[5][y + 1] - v[5][x]; if (AT + AC != TA + CA || TA + TC != AT + CT) return -1; int swaps = std::min(TC, CT) + std::min(AT, TA) + std::min(AC, CA); int TCT = std::max(TC, CT) - std::min(TC, CT); int ATA = std::max(AT, TA) - std::min(AT, TA); int CAC = std::max(AC, CA) - std::min(AC, CA); return swaps + 2*TCT; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:45:6: warning: unused variable 'ATA' [-Wunused-variable]
   45 |  int ATA = std::max(AT, TA) - std::min(AT, TA);
      |      ^~~
dna.cpp:46:6: warning: unused variable 'CAC' [-Wunused-variable]
   46 |  int CAC = std::max(AC, CA) - std::min(AC, CA);
      |      ^~~
#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...