This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//yo dayo
#include <bits/stdc++.h>
using namespace std;
int a[1000005][7],n,q,x,y,res,tmp;
int ac,at,ca,ct,ta,tc;
string s1,s2;
void init(string a1, string b1){
s1=a1;
s2=b1;
n=s1.size();
for (int i=0;i<n;i++){
if (i){
a[i][1]=a[i-1][1];
a[i][2]=a[i-1][2];
a[i][3]=a[i-1][3];
a[i][4]=a[i-1][4];
a[i][5]=a[i-1][5];
a[i][6]=a[i-1][6];
}
if (s1[i]=='A' && s2[i]=='C') a[i][1]++;
if (s1[i]=='A' && s2[i]=='T') a[i][2]++;
if (s1[i]=='C' && s2[i]=='A') a[i][3]++;
if (s1[i]=='C' && s2[i]=='T') a[i][4]++;
if (s1[i]=='T' && s2[i]=='A') a[i][5]++;
if (s1[i]=='T' && s2[i]=='C') a[i][6]++;
}
}
int d1 (int x, int y, int i){
if (x) return a[y][i]-a[x-1][i];
return a[y][i];
}
int get_distance(int x, int y){
ac=d1(x,y,1);
at=d1(x,y,2);
ca=d1(x,y,3);
ct=d1(x,y,4);
ta=d1(x,y,5);
tc=d1(x,y,6);
if ((ac+at!=ca+ta) || (ca+ct!=tc+ac) || (ta+tc!=at+ct)) return -1;
res=0;
tmp=min(ac,ca);
res+=tmp;
ac-=tmp;
ca-=tmp;
tmp=min(at,ta);
res+=tmp;
at-=tmp;
ta-=tmp;
tmp=min(tc,ct);
res+=tmp;
tc-=tmp;
ct-=tmp;
tmp=max(max(tc,ct),max(max(ac,ca),max(at,ta)));
res+=tmp*2;
return res;
}
# | 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... |