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>
using namespace std;
using ll = long long;
ll n, m, q, k, x, y, a, b, c;
ll same[100001];
map<char, int> mpa[100001];
map<char, int> mpb[100001];
void init(string a, string b) {
for (int i = 0; i < a.size(); i++) {
if (a[i] == b[i]) {
same[i + 1]++;
}
same[i + 1] += same[i];
mpa[i + 1] = mpa[i];
mpb[i + 1] = mpb[i];
mpa[i + 1][a[i]]++;
mpb[i + 1][b[i]]++;
}
}
int get_distance(int x, int y) {
for (auto i : {'A', 'T', 'C'}) {
// cout << i << ' ' << mpa[y + 1][i] - mpa[x][i] << ' ' << mpb[y + 1][i] - mpb[x][i] << '\n';
if (mpa[y + 1][i] - mpa[x][i] != mpb[y + 1][i] - mpb[x][i]) {
return -1;
}
}
return (y - x) - (same[y + 1] - same[x]);
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for (int i = 0; i < a.size(); 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... |