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 + 5;
int n;
int c[3][3][mxN];
int encode(char ch) {
if (ch == 'A') return 0;
if (ch == 'T') return 1;
return 2;
}
void init(std::string a, std::string b) {
n = a.size();
for (int i = 0; i < n; ++i) {
int x = encode(a[i]);
int y = encode(b[i]);
c[x][y][i + 1]++;
}
for (int i = 1; i <= n; ++i) {
for (int x = 0; x < 3; ++x)
for (int y = 0; y < 3; ++y)
c[x][y][i] += c[x][y][i - 1];
}
}
int get_distance(int l, int r) {
++r;
int res = -1;
vector<vector<int>> f(3, vector<int>(3));
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j) {
f[i][j] = c[i][j][r] - c[i][j][l];
}
int x = f[0][1] - f[1][0];
int y = f[0][2] - f[2][0];
int z = f[1][2] - f[2][1];
if ((x == -y && -y == z) || (-x == y && y == -z)) {
res = min(f[0][1], f[1][0]) + min(f[0][2], f[2][0]) + min(f[1][2], f[2][1]);
x = abs(x);
res += x * 2;
}
return res;
}
# | 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... |