제출 #442073

#제출 시각아이디문제언어결과실행 시간메모리
442073daniel920712DNA 돌연변이 (IOI21_dna)C++17
100 / 100
46 ms8468 KiB
#include "dna.h" #include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; int con[5][5][100005]={0}; int con2[5][100005]={0}; int con3[5][100005]={0}; void init(string a,string b) { int N=a.size(),i,j,k; for(i=0;i<N;i++) { for(j=0;j<3;j++) { con2[j][i+1]=con2[j][i]; con3[j][i+1]=con3[j][i]; for(k=0;k<3;k++) con[j][k][i+1]=con[j][k][i]; } if(a[i]=='A') { con2[0][i+1]++; if(b[i]=='A') con[0][0][i+1]++; if(b[i]=='T') con[0][1][i+1]++; if(b[i]=='C') con[0][2][i+1]++; } if(a[i]=='T') { con2[1][i+1]++; if(b[i]=='A') con[1][0][i+1]++; if(b[i]=='T') con[1][1][i+1]++; if(b[i]=='C') con[1][2][i+1]++; } if(a[i]=='C') { con2[2][i+1]++; if(b[i]=='A') con[2][0][i+1]++; if(b[i]=='T') con[2][1][i+1]++; if(b[i]=='C') con[2][2][i+1]++; } if(b[i]=='A') con3[0][i+1]++; if(b[i]=='T') con3[1][i+1]++; if(b[i]=='C') con3[2][i+1]++; } } int get_distance(int x, int y) { int ans=0; x++; y++; if(con2[0][y]-con2[0][x-1]!=con3[0][y]-con3[0][x-1]) return -1; if(con2[1][y]-con2[1][x-1]!=con3[1][y]-con3[1][x-1]) return -1; if(con2[2][y]-con2[2][x-1]!=con3[2][y]-con3[2][x-1]) return -1; ans+=min(con[0][1][y]-con[0][1][x-1],con[1][0][y]-con[1][0][x-1]); ans+=min(con[1][2][y]-con[1][2][x-1],con[2][1][y]-con[2][1][x-1]); ans+=min(con[0][2][y]-con[0][2][x-1],con[2][0][y]-con[2][0][x-1]); ans+=2*abs((con[0][1][y]-con[0][1][x-1])-(con[1][0][y]-con[1][0][x-1])); 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...