This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, std::greater<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define fastio std::cin.tie(0), std::cout.tie(0), std::ios_base::sync_with_stdio(false)
#define rep(a, b, c, d) for (int a = b; a < c; a += d)
#define INF ((1ll << 62) - 1)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
using namespace std;
#define MN 200000
//#define int long long
#define mod (long long)(1e9 + 7)
#define mod2 (long long)(1000004099ll)
//#define int unsigned long long
//#define int long long
vector<int> aac, acc, atc;
vector<int> cor;
vector<int> bac, bcc, btc;
int gt(int pos, vector<int>& v) {
if (pos < 0) return 0;
return v[pos];
}
int gs(int l, int r, vector<int>& v) {
return gt(r, v) - gt(l - 1, v);
}
int get_distance(int x, int y) {
if (gs(x, y, aac) != gs(x, y, bac) || gs(x, y, acc) != gs(x, y, bcc) || gs(x, y, atc) != gs(x, y, btc)) {
return -1;
}
return ((y - x + 1) - gs(x, y, cor) + 1) / 2;
}
void init(string a, string b) {
int n = a.size();
cor.resize(n);
aac.resize(n), acc.resize(n), atc.resize(n);
bac.resize(n), bcc.resize(n), btc.resize(n);
for (int i = 0; i < n; ++i) {
aac[i] = gt(i - 1, aac);
acc[i] = gt(i - 1, acc);
atc[i] = gt(i - 1, atc);
if (a[i] == 'A') {
aac[i]++;
} else if (a[i] == 'T') {
atc[i]++;
} else {
acc[i]++;
}
}
for (int i = 0; i < n; ++i) {
bac[i] = gt(i - 1, bac);
bcc[i] = gt(i - 1, bcc);
btc[i] = gt(i - 1, btc);
if (b[i] == 'A') {
bac[i]++;
} else if (b[i] == 'T') {
btc[i]++;
} else {
bcc[i]++;
}
}
for (int i = 0; i < n; ++i) {
cor[i] = gt(i - 1, cor);
if (a[i] == b[i]) {
cor[i]++;
}
}
}
# | 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... |