제출 #629772

#제출 시각아이디문제언어결과실행 시간메모리
629772Cross_RatioDNA 돌연변이 (IOI21_dna)C++17
100 / 100
58 ms9736 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; int B[100005][9]; int A[100005][6]; int sum(int x, int y, int type) { return B[y-1][type] - (x ? B[x-1][type]:0); } int sum2(int x, int y, int type) { return A[y-1][type] - (x ? A[x-1][type]:0); } map<char,int> M; int L; void init(string a, string b) { M['A']=0; M['T']=1; M['C']=2; int i, j; L = a.length(); for(i=0;i<L;i++) { B[i][3*M[a[i]]+M[b[i]]]++; } for(i=1;i<L;i++) { for(j=0;j<9;j++) B[i][j] += B[i-1][j]; } for(i=0;i<L;i++) { A[i][M[a[i]]]++; A[i][M[b[i]]+3]++; } for(i=1;i<L;i++) { for(j=0;j<6;j++) A[i][j] += A[i-1][j]; } } int get_distance(int x, int y) { y++; for(int i = 0; i < 3; i++) { if(sum2(x, y, i) != sum2(x, y, i+3)) return -1; } int ans = 0; int ca = sum(x, y, 6); int ac = sum(x, y, 2); int ta = sum(x, y, 3); int at = sum(x, y, 1); int ct = sum(x, y, 7); int tc = sum(x, y, 5); ans += min(ca, ac) + min(ta, at) + min(ct, tc); ans += 2*max({max(ca,ac)-min(ca,ac),max(ta,at)-min(ta,at),max(ct,tc)-min(ct,tc)}); 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...