제출 #483559

#제출 시각아이디문제언어결과실행 시간메모리
483559M_WDNA 돌연변이 (IOI21_dna)C++17
100 / 100
40 ms6212 KiB
#include <bits/stdc++.h> using namespace std; int qs[100001][6]; // AT, TA, AC, CA, CT, TC void init(string a, string b){ int len = a.size(); for(int i = 1; i <= len; i++){ for(int j = 0; j < 6; j++) qs[i][j] = qs[i - 1][j]; if(a[i - 1] == 'A'){ if(b[i - 1] == 'C') qs[i][2]++; else if(b[i - 1] == 'T') qs[i][0]++; } else if(a[i - 1] == 'T'){ if(b[i - 1] == 'A') qs[i][1]++; else if(b[i - 1] == 'C') qs[i][5]++; } else{ if(b[i - 1] == 'A') qs[i][3]++; else if(b[i - 1] == 'T') qs[i][4]++; } } } int get_distance(int a, int b){ a++; b++; int AT = qs[b][0] - qs[a - 1][0]; int TA = qs[b][1] - qs[a - 1][1]; int AC = qs[b][2] - qs[a - 1][2]; int CA = qs[b][3] - qs[a - 1][3]; int CT = qs[b][4] - qs[a - 1][4]; int TC = qs[b][5] - qs[a - 1][5]; int A1 = AT + AC, C1 = CA + CT, T1 = TA + TC; int A2 = TA + CA, C2 = AC + TC, T2 = AT + CT; if(A1 != A2 || C1 != C2 || T1 != T2) return -1; int ATp = min(AT, TA), ACp = min(AC, CA), TCp = min(TC, CT); int ret = ATp + ACp + TCp; AT -= ATp; TA -= ATp; AC -= ACp; CA -= ACp; TC -= TCp; CT -= TCp; ret += ((AC + CT + TA) / 3) * 2; ret += ((CA + AT + TC) / 3) * 2; return ret; }
#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...