제출 #1189619

#제출 시각아이디문제언어결과실행 시간메모리
1189619njoopDNA 돌연변이 (IOI21_dna)C++20
0 / 100
20 ms5632 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; int n, dp[100010][3][3]; void init(string a, string b) { n = a.size(); for(int i=1; i<=n; i++) { int x, y; if(a[i-1] == 'C') x = 0; else if(a[i-1] == 'A') x = 1; else x = 2; if(b[i-1] == 'C') y = 0; else if(b[i-1] == 'A') y = 1; else y = 2; dp[i][x][y]++; for(int j=0; j<3; j++) { for(int k=0; k<3; k++) { dp[i][j][k] += dp[i-1][j][k]; } } } } int get_distance(int x, int y) { x++; y++; int ans = 0; int ca = dp[y][0][1]-dp[x-1][0][1], ac = dp[y][1][0]-dp[x-1][1][0], ct = dp[y][0][2]-dp[x-1][0][2], tc = dp[y][2][0]-dp[x-1][2][0], at = dp[y][1][2]-dp[x-1][1][2], ta = dp[y][2][1]-dp[x-1][2][1]; if(at+ac-ta-tc != 0 || tc+ta-at-ac != 0 || ca+ct-tc-ta != 0) return -1; int t = min(ta, at); ans += t; ta -= t; at -= t; t = min(ac, ca); ans += t; ac -= t; ca -= t; t = min(ct, tc); ans += t; ct -= t; tc -= t; ans += ((ac+at+ca+ct+ta+tc)*2)/3; 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...