#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>
bool assign_min(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<typename T>
bool assign_max(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
vector<int> prefAA, prefAT, prefAC;
vector<int> prefBA, prefBT, prefBC;
vector<int> pref;
void init(string a, string b) {
int n = a.size();
prefAA.resize(n + 1);
prefAT.resize(n + 1);
prefAC.resize(n + 1);
for (int i = 1; i <= a.size(); i++) {
prefAA[i] = prefAA[i - 1] + (a[i - 1] == 'A');
prefAT[i] = prefAT[i - 1] + (a[i - 1] == 'T');
prefAC[i] = prefAC[i - 1] + (a[i - 1] == 'C');
}
prefBA.resize(n + 1);
prefBT.resize(n + 1);
prefBC.resize(n + 1);
for (int i = 1; i <= b.size(); i++) {
prefBA[i] = prefBA[i - 1] + (b[i - 1] == 'A');
prefBT[i] = prefBT[i - 1] + (b[i - 1] == 'T');
prefBC[i] = prefBC[i - 1] + (b[i - 1] == 'C');
}
pref.resize(n + 1);
for (int i = 1; i <= n; i++) {
pref[i] = pref[i - 1] + (a[i - 1] != b[i - 1]);
}
}
int get_distance(int x, int y) {
x++;
y++;
if (prefAA[y] - prefAA[x - 1] != prefBA[y] - prefBA[x - 1]) {
return -1;
}
if (prefAT[y] - prefAT[x - 1] != prefBT[y] - prefBT[x - 1]) {
return -1;
}
if (prefAC[y] - prefAC[x - 1] != prefBC[y] - prefBC[x - 1]) {
return -1;
}
return (pref[y] - pref[x - 1] + 1) / 2;
}
# | 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... |