Submission #819914

#TimeUsernameProblemLanguageResultExecution timeMemory
819914Marco_EscandonMutating DNA (IOI21_dna)C++17
100 / 100
32 ms8760 KiB
#include<bits/stdc++.h> using namespace std; #define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0); #pragma GCC optimize("Ofast") typedef long long ll; ll AT[100002]={ },AC[100002]={ },TC[100002]={ }; ll TA[100002]={ },CA[100002]={ },CT[100002]={ }; ll n; void init(string a, string b) { n=a.size(); for(int i=0; i<n; i++) { if(a[i]=='A'&&b[i]=='T')AT[i+1]=1; if(a[i]=='A'&&b[i]=='C')AC[i+1]=1; if(a[i]=='T'&&b[i]=='C')TC[i+1]=1; if(a[i]=='T'&&b[i]=='A')TA[i+1]=1; if(a[i]=='C'&&b[i]=='A')CA[i+1]=1; if(a[i]=='C'&&b[i]=='T')CT[i+1]=1; if(i>0) { AT[i+1]+=AT[i]; AC[i+1]+=AC[i]; TC[i+1]+=TC[i]; TA[i+1]+=TA[i]; CA[i+1]+=CA[i]; CT[i+1]+=CT[i]; } } } int get_distance(int x,int y) { x++; y++; ll AT1=AT[y]-AT[x-1], TA1=TA[y]-TA[x-1], CT1=CT[y]-CT[x-1]; ll AC1=AC[y]-AC[x-1], TC1=TC[y]-TC[x-1], CA1=CA[y]-CA[x-1]; ll a1=AT1+AC1, t1=TC1+TA1 ,c1=CA1+CT1; ll a2=TA1+CA1, t2=AT1+CT1 ,c2=AC1+TC1; //cout<<a1<<a2<<" "<<t1<<t2<<" "<<c1<<c2; if(a1!=a2||t1!=t2||c1!=c2)return -1; else { return min(AT1,TA1)+min(AC1,CA1)+min(CT1,TC1)+(max(AT1,TA1)-min(AT1,TA1))*2; } }
#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...