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;
const int val = 1e5+5;
string s,t;
int AT[val], AC[val], TC[val], TA[val],CA[val], CT[val];
int n;
void init(string a,string b){
n = a.size();
for(int32_t i = 0; i < (n+1); i++) {
AT[i] = AC[i] = TC[i] = TA[i] = CA[i] = CT[i] = 0;
}
for(int32_t i = 0; i < (n); i++) {
if (a[i] == 'A' && b[i] == 'T') AT[i+1]++;
if (a[i] == 'A' && b[i] == 'C') AC[i+1]++;
if (a[i] == 'T' && b[i] == 'C') TC[i+1]++;
if (a[i] == 'T' && b[i] == 'A') TA[i+1]++;
if (a[i] == 'C' && b[i] == 'A') CA[i+1]++;
if (a[i] == 'C' && b[i] == 'T') CT[i+1]++;
}
for(int32_t i = 1; i <= (n); i++) {
AT[i] += AT[i-1];
AC[i] += AC[i-1];
TC[i] += TC[i-1];
TA[i] += TA[i-1];
CA[i] += CA[i-1];
CT[i] += CT[i-1];
}
}
int get_distance(int x, int y)
{
x ++, y ++;
int at = AT[y] - AT[x-1];
int ac = AC[y] - AC[x-1];
int tc = TC[y] - TC[x-1];
int ta = TA[y] - TA[x-1];
int ca = CA[y] - CA[x-1];
int ct = CT[y] - CT[x-1];
int ans = 0;
int min1 = min(at, ta);
int min2 = min(ac, ca);
int min3 = min(tc, ct);
ans += min1 + min2 + min3;
at -= min1; ta -= min1;
ac -= min2; ca -= min2;
tc -= min3; ct -= min3;
if( (at == tc && tc == ca) && (ta == ac && ac == ct) )
{
ans += at + ta + ac + ca;
return ans;
}
return -1;
}
# | 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... |