This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |