Submission #1128619

#TimeUsernameProblemLanguageResultExecution timeMemory
1128619Lincito_31Mutating DNA (IOI21_dna)C++20
100 / 100
41 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]++; if(b[i-1]=='C')psumAC[i]++; }else if(a[i-1]=='T'){ if(b[i-1]=='A')psumTA[i]++; if(b[i-1]=='C')psumTC[i]++; }else{ if(b[i-1]=='A')psumCA[i]++; 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],CA=psumCA[y+1]-psumCA[x],AT=psumAT[y+1]-psumAT[x],TA=psumTA[y+1]-psumTA[x],TC=psumTC[y+1]-psumTC[x],CT=psumCT[y+1]-psumCT[x]; int con1=min(AC,CA),con2=min(AT,TA),con3=min(TC,CT); return con1+con2+con3+((AC+CA+TA+AT+CT+TC-2*con1-2*con2-2*con3)/3)*2;; }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...