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>
#include "dna.h"
using namespace std;
using ll = long long;
int cnt[100005][3][3], c[256];
int ps (int x, int y, int i, int j) {
return cnt[y][i][j] - (x ? cnt[x-1][i][j] : 0);
}
void init(string a, string b) {
c['A'] = 0;
c['T'] = 1;
c['C'] = 2;
int n = a.size();
for (int i = 0; i < n; i++) for (int j = 0; j < 3; j++) for (int k = 0; k < 3; k++) if (j != k)
cnt[i][j][k] = (c[(int) a[i]] == j && c[(int) b[i]] == k) + (i ? cnt[i-1][j][k] : 0);
}
int get_distance(int x, int y) {
int diff[3][3], ans = 0;
for (int i = 0; i < 2; i++) for (int j = i+1; j < 3; j++) {
diff[i][j] = abs(ps(x, y, i, j) - ps(x, y, j, i));
ans += min(ps(x, y, i, j), ps(x, y, j, i));
}
if (diff[0][1] == diff[0][2] && diff[0][2] == diff[1][2])
if ((ps(x, y, 0, 1) > ps(x, y, 1, 0)) == (ps(x, y, 1, 2) > ps(x, y, 2, 1)) && (ps(x, y, 1, 2) > ps(x, y, 2, 1)) == (ps(x, y, 2, 0) > ps(x, y, 0, 2)))
return ans + (diff[0][1] + diff[0][2] + diff[1][2]) * 2 / 3;
return -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... |