제출 #480387

#제출 시각아이디문제언어결과실행 시간메모리
480387inventiontimeDNA 돌연변이 (IOI21_dna)C++17
100 / 100
55 ms10108 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; #define MAXN 100005 int n; int pairs[3][3][MAXN]; int of[2][3][MAXN]; int diff[MAXN]; map<char, int> code = {{'A', 0}, {'T', 1}, {'C', 2}}; void init(std::string a, std::string b) { n = a.length(); diff[0] = 0; for(int i = 0; i < 3; i++) { for(int j = 0; j < 2; j++) of[j][i][0] = 0; for(int j = 0; j < 3; j++) pairs[j][i][0] = 0; } for(int i = 1; i <= n; i++) { for(int j = 0; j < 2; j++) for(int k = 0; k < 3; k++) of[j][k][i] = of[j][k][i-1]; for(int j = 0; j < 3; j++) for(int k = 0; k < 3; k++) pairs[j][k][i] = pairs[j][k][i-1]; diff[i] = diff[i-1]; of[0][code[a[i-1]]][i]++; of[1][code[b[i-1]]][i]++; if(a[i-1] != b[i-1]) { diff[i]++; pairs[code[a[i-1]]][code[b[i-1]]][i]++; } } } int swaps(int x, int y, int n1, int n2) { return min(pairs[n1][n2][y] - pairs[n1][n2][x], pairs[n2][n1][y] - pairs[n2][n1][x]); } int get_distance(int x, int y) { x--; x++; y++; if(of[0][0][y] - of[0][0][x] == of[1][0][y] - of[1][0][x] && of[0][1][y] - of[0][1][x] == of[1][1][y] - of[1][1][x] && of[0][2][y] - of[0][2][x] == of[1][2][y] - of[1][2][x]) { int one_swap = swaps(x, y, 0, 1) + swaps(x, y, 1, 2) + swaps(x, y, 2, 0); float two_swap = (float) (diff[y] - diff[x] - 2*one_swap)/3; return ((diff[y] - diff[x]) - 2*one_swap)*2/3 + one_swap; } return -1; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:50:9: warning: unused variable 'two_swap' [-Wunused-variable]
   50 |   float two_swap = (float) (diff[y] - diff[x] - 2*one_swap)/3;
      |         ^~~~~~~~
#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...