제출 #1128618

#제출 시각아이디문제언어결과실행 시간메모리
1128618Lincito_31DNA 돌연변이 (IOI21_dna)C++20
100 / 100
32 ms6728 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string x,y; int n; vector<int> psumTA,psumAT,psumTC,psumCT,psumAC,psumCA,cantiAa,cantiTa,cantiAb,cantiTb; void init(string a,string b){ x=a;y=b; n=a.size(); psumTA.resize(n+1); psumAT.resize(n+1); psumCA.resize(n+1); psumAC.resize(n+1); psumTC.resize(n+1); psumCT.resize(n+1); cantiAa.resize(n+1); cantiTa.resize(n+1); cantiTb.resize(n+1); cantiAb.resize(n+1); for(int i=1;i<=n;i++){ cantiAa[i]=cantiAa[i-1]+(a[i-1]=='A'); cantiTa[i]=cantiTa[i-1]+(a[i-1]=='T'); cantiAb[i]=cantiAb[i-1]+(b[i-1]=='A'); cantiTb[i]=cantiTb[i-1]+(b[i-1]=='T'); psumAC[i]=psumAC[i-1]; psumCA[i]=psumCA[i-1]; psumTA[i]=psumTA[i-1]; psumAT[i]=psumAT[i-1]; psumTC[i]=psumTC[i-1]; psumCT[i]=psumCT[i-1]; if(a[i-1]=='A'){ if(b[i-1]=='T'){ psumAT[i]++; }else if(b[i-1]=='C'){ psumAC[i]++; } }else if(a[i-1]=='T'){ if(b[i-1]=='A'){ psumTA[i]++; }else if(b[i-1]=='C'){ psumTC[i]++; } }else{ if(b[i-1]=='A'){ psumCA[i]++; }else if(b[i-1]=='T'){ psumCT[i]++; } } } } int get_distance(int x, int y){ if((cantiAa[y+1]-cantiAa[x]==cantiAb[y+1]-cantiAb[x]) && (cantiTa[y+1]-cantiTa[x]==cantiTb[y+1]-cantiTb[x])){ int AC=psumAC[y+1]-psumAC[x]; int CA=psumCA[y+1]-psumCA[x]; int AT=psumAT[y+1]-psumAT[x]; int TA=psumTA[y+1]-psumTA[x]; int TC=psumTC[y+1]-psumTC[x]; int CT=psumCT[y+1]-psumCT[x]; int con1=min(AC,CA),con2=min(AT,TA),con3=min(TC,CT); int res=con1+con2+con3; AC-=con1; CA-=con1; AT-=con2; TA-=con2; CT-=con3; TC-=con3; int queda=AC+CA+TA+AT+CT+TC; res+=(queda/3)*2; return res; }else{ 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...