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>
#include "dna.h"
using namespace std;
typedef long long ll;
const ll N=(1e5)+10;
ll n;
vector<ll> AT(N, 0);
vector<ll> TA(N, 0);
vector<ll> CA(N, 0);
vector<ll> AC(N, 0);
vector<ll> TC(N, 0);
vector<ll> CT(N, 0);
void init(string a, string b) {
n=a.length();
a="."+a;
b="."+b;
for(ll i=1; i<=n; i++){
AT[i]=AT[i-1];
TA[i]=TA[i-1];
AC[i]=AC[i-1];
CA[i]=CA[i-1];
CT[i]=CT[i-1];
TC[i]=TC[i-1];
if(a[i]=='T' && b[i]=='A') TA[i]++;
else if(a[i]=='A' && b[i]=='T') AT[i]++;
else if(a[i]=='A' && b[i]=='C') AC[i]++;
else if(a[i]=='C' && b[i]=='A') CA[i]++;
else if(a[i]=='C' && b[i]=='T') CT[i]++;
else if(a[i]=='T' && b[i]=='C') TC[i]++;
}
}
int get_distance(int x, int y) {
x++, y++;
ll ac=AC[y]-AC[x-1];
ll ca=CA[y]-CA[x-1];
ll at=AT[y]-AT[x-1];
ll ta=TA[y]-TA[x-1];
ll tc=TC[y]-TC[x-1];
ll ct=CT[y]-CT[x-1];
ll k=0;
if(ca+ta!=ac+at) return -1;
if(ct+at!=tc+ta) return -1;
if(ac+tc!=ca+ct) return -1;
if(ca<ac){
swap(ca, ac);
swap(at, ta);
swap(tc, ct);
}
k+=ac+ta+ct;
k+=2*(ca-ac);
return k;
}
# | 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... |