제출 #858244

#제출 시각아이디문제언어결과실행 시간메모리
858244lentibearDNA 돌연변이 (IOI21_dna)C++17
100 / 100
32 ms6284 KiB
#include <string> #include <vector> using namespace std; void init(std::string a, std::string b); int get_distance(int x, int y); vector<int> ct[6]; void init(std::string a, std::string b){ int n=min(a.size(),b.size()); for(int j=0; j<6; j++) ct[j]= vector<int> (n); for(int i=0; i<n; i++) { if(i>0) for(int j=0; j<6; j++) ct[j][i]=ct[j][i-1]; else for(int j=0; j<6; j++) ct[j][i]=0; if(a[i]=='A'){ if(b[i]=='T') ct[0][i]++; else if (b[i]=='C') ct[1][i]++; } if(a[i]=='T'){ if(b[i]=='A') ct[2][i]++; else if (b[i]=='C') ct[3][i]++; } if(a[i]=='C'){ if(b[i]=='A') ct[4][i]++; else if (b[i]=='T') ct[5][i]++; } } } int get_distance(int x, int y){ int nct[6]; for(int j=0; j<6; j++) nct[j]=ct[j][y]; if(x>0) for(int j=0; j<6; j++) nct[j]-=ct[j][x-1]; if(nct[0]+nct[1]==nct[2]+nct[4] && nct[2]+nct[3]==nct[0]+nct[5]){ return(min(nct[0], nct[2])+min(nct[1],nct[4])+min(nct[3],nct[5])+max(nct[0]-nct[2],0)*2+max(nct[1]-nct[4],0)*2); } return(-1); }
#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...