제출 #818112

#제출 시각아이디문제언어결과실행 시간메모리
818112alvingogoDNA 돌연변이 (IOI21_dna)C++17
35 / 100
39 ms6048 KiB
#include "dna.h" #include <bits/stdc++.h> #define fs first #define sc second #define p_q priority_queue using namespace std; int n; vector<int> pre[3][3]; void init(string a, string b) { map<char,int> m; m['A']=0; m['C']=1; m['T']=2; n=a.length(); for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ pre[i][j].resize(n); } } for(int i=0;i<n;i++){ pre[m[a[i]]][m[b[i]]][i]++; } for(int i=1;i<n;i++){ for(int j=0;j<3;j++){ for(int k=0;k<3;k++){ pre[j][k][i]+=pre[j][k][i-1]; } } } } int get_distance(int x, int y) { int z[3][3]={0}; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ z[i][j]=pre[i][j][y]; if(x){ z[i][j]-=pre[i][j][x-1]; } } } int ans=0; ans+=min(z[0][1],z[1][0]); ans+=min(z[0][2],z[2][0]); ans+=min(z[1][2],z[2][1]); int a=z[1][0]+z[0][1]-2*min(z[0][1],z[1][0]); int b=z[1][2]+z[2][1]-2*min(z[2][1],z[1][2]); int c=z[2][0]+z[0][2]-2*min(z[0][2],z[2][0]); if(a!=b || b!=c){ return -1; } return ans+2*a; }
#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...