제출 #1048277

#제출 시각아이디문제언어결과실행 시간메모리
1048277parsadox2DNA 돌연변이 (IOI21_dna)C++17
71 / 100
1538 ms3932 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n; string a , b; int f(char c) { if(c == 'A') return 0; else if(c == 'C') return 1; else return 2; } void init(string aa, string bb) { n = aa.size(); a = aa; b = bb; } int get_distance(int x, int y) { int cnt[3][3]; int ca[3] , cb[3]; memset(cnt , 0 , sizeof cnt); memset(ca , 0 , sizeof ca); memset(cb , 0 , sizeof cb); for(int i = x ; i <= y ; i++) { ca[f(a[i])]++; cb[f(b[i])]++; cnt[f(a[i])][f(b[i])]++; } for(int i = 0 ; i < 3 ; i++) if(ca[i] != cb[i]) return -1; int ans = 0; for(int i = 0 ; i < 2 ; i++) for(int j = i + 1 ; j < 3 ; j++) { int mn = min(cnt[i][j] , cnt[j][i]); cnt[i][j] -= mn; cnt[j][i] -= mn; ans += mn; } for(int i = 0 ; i < 2 ; i++) { ans += cnt[i][2]; ans += cnt[2][i]; } return ans; }
#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...