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 "dna.h"
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5 + 1;
int ps[2][mxN][3];
map<char, int> conv = {{'A', 0}, {'C', 1}, {'T', 2}};
void init(string a, string b) {
int n = a.length();
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 3; j++) {
ps[0][i][j] = ps[0][i - 1][j];
ps[1][i][j] = ps[1][i - 1][j];
}
if (a[i - 1] == b[i - 1]) continue;
ps[0][i][conv[a[i - 1]]]++;
ps[1][i][conv[b[i - 1]]]++;
}
}
int get_distance(int x, int y) {
x++; y++;
int ans = 0;
for (int i = 0; i < 3; i++) {
if (ps[0][y][i] - ps[0][x - 1][i] != ps[1][y][i] - ps[1][x - 1][i]) return -1;
ans += ps[0][y][i] - ps[0][x - 1][i];
}
return ans / 2 + ans % 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... |