#include <bits/stdc++.h>
// mrrrow meeow :3
// go play vivid/stasis now! it's free on steam
#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;
int ____init = [] {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
return 0;
}();
struct Node {
int ne = 0;
int aa = 0, at = 0, ac = 0;
int ba = 0, bt = 0, bc = 0;
Node operator+(const Node &other) const {
Node res;
res.ne = ne + other.ne;
res.aa = aa + other.aa;
res.at = at + other.at;
res.ac = ac + other.ac;
res.ba = ba + other.ba;
res.bt = bt + other.bt;
res.bc = bc + other.bc;
return res;
}
Node operator-(const Node &other) const {
Node res;
res.ne = ne - other.ne;
res.aa = aa - other.aa;
res.at = at - other.at;
res.ac = ac - other.ac;
res.ba = ba - other.ba;
res.bt = bt - other.bt;
res.bc = bc - other.bc;
return res;
}
bool valid() const {
return aa == ba && at == bt && ac == bc;
}
};
Node bit[100001];
Node get(int i) {
Node res;
for (i++; i > 0; i -= i & -i) res = res + bit[i];
return res;
}
void add(int i, Node v) {
for (i++; i <= 100000; i += i & -i) bit[i] = bit[i] + v;
}
bool any_cs = false;
void init(string a, string b) {
fo(i, 0, a.size()) {
Node res;
res.ne = a[i] != b[i];
res.aa = a[i] == 'A';
res.at = a[i] == 'T';
res.ac = a[i] == 'C';
res.ba = b[i] == 'A';
res.bt = b[i] == 'T';
res.bc = b[i] == 'C';
add(i, res);
any_cs = any_cs || a[i] == 'C' || b[i] == 'C';
}
}
int get_distance(int x, int y) {
Node res = get(y) - get(x - 1);
return res.valid() ? any_cs ? max(res.ne - 1, 0) : res.ne / 2 : -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... |