#include "dna.h"
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
string a, b;
vector<int> ta(1e5 + 1), at(1e5 + 1), ct(1e5 + 1), tc(1e5 + 1), ac(1e5 + 1), ca(1e5 + 1);
void init(string A, string B){
a = A, b = B;
int n = a.size();
for(int i = 0; i < n; i++){
ta[i] = ta[i - 1] + (a[i - 1] == 'T' && b[i - 1] == 'A');
at[i] = at[i - 1] + (a[i - 1] == 'A' && b[i - 1] == 'T');
tc[i] = tc[i - 1] + (a[i - 1] == 'T' && b[i - 1] == 'C');
ct[i] = ct[i - 1] + (a[i - 1] == 'C' && b[i - 1] == 'T');
ac[i] = ac[i - 1] + (a[i - 1] == 'A' && b[i - 1] == 'C');
ca[i] = ca[i - 1] + (a[i - 1] == 'C' && b[i - 1] == 'A');
}
}
int get_distance(int x, int y){
int cat = at[y + 1] - at[x];
int cta = ta[y + 1] - ta[x];
int ctc = tc[y + 1] - tc[x];
int cct = ct[y + 1] - ct[x];
int cac = ac[y + 1] - ac[x];
int cca = ca[y + 1] - ca[x];
if(!(cta + ctc == cat + cct && cat + cac == cta + cca && cct + cca == ctc + cac)) return -1;
int r1 = abs(cat - cta), r2 = abs(cac - cca), r3 = abs(cct - ctc);
int s = min(cat, cta) + min(cac, cca) + min(cct, ctc);
return (r1 + r2 + r3) * 2 / 3 + s;
}
# | 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... |