Submission #954821

#TimeUsernameProblemLanguageResultExecution timeMemory
9548214QT0RMutating DNA (IOI21_dna)C++17
100 / 100
31 ms6156 KiB
#include <bits/stdc++.h> using namespace std; int ac[100002]; int ca[100002]; int at[100002]; int ta[100002]; int ct[100002]; int tc[100002]; int n; void init(string a, string b){ n=a.size(); for (int i = 1; i<=n; i++){ ac[i]=ac[i-1]; ca[i]=ca[i-1]; at[i]=at[i-1]; ta[i]=ta[i-1]; ct[i]=ct[i-1]; tc[i]=tc[i-1]; if (a[i-1]=='A'){ if (b[i-1]=='C')ac[i]++; if (b[i-1]=='T')at[i]++; } else if (a[i-1]=='C'){ if (b[i-1]=='A')ca[i]++; if (b[i-1]=='T')ct[i]++; } else{ if (b[i-1]=='A')ta[i]++; if (b[i-1]=='C')tc[i]++; } } } int get_distance(int x, int y){ y++; int pac=ac[y]-ac[x]; int pca=ca[y]-ca[x]; int pat=at[y]-at[x]; int pta=ta[y]-ta[x]; int pct=ct[y]-ct[x]; int ptc=tc[y]-tc[x]; int ans=0; int a1=pac+pat,a2=pca+pta,t1=pta+ptc,t2=pat+pct,c1=pca+pct,c2=pac+ptc; if (a1!=a2 || t1!=t2 || c1!=c2)return -1; if (pca<pac){ ans+=pca; pac-=pca; ans+=2*pac; } else{ ans+=pac; pca-=pac; ans+=2*pca; } if (pat<pta){ ans+=pat; pta-=pat; } else{ ans+=pta; pat-=pta; } if (pct<ptc){ ans+=pct; ptc-=pct; } else{ ans+=ptc; pct-=ptc; } 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...