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;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define MAX 100000
lli acu[MAX+2][3][3];
lli act[3][3];
void init(std::string a, std::string b) {
lli n = a.size();
lli x,y;
rep(i,0,n-1) {
if (a[i] == 'A') x = 0;
else if (a[i] == 'T') x = 1;
else x = 2;
if (b[i] == 'A') y = 0;
else if (b[i] == 'T') y = 1;
else y = 2;
rep(e,0,2) rep(j,0,2) acu[i][e][j] = acu[i-1][e][j];
acu[i][x][y]++;
}
}
int get_distance(int x, int y) {
rep(i,0,2) rep(j,0,2) act[i][j] = acu[y][i][j];
rep(i,0,2) rep(j,0,2) act[i][j] -= acu[x][i][j];
lli a,b,c,res = 0;
res += min(act[0][2], act[2][0]);
a = abs(act[0][2] - act[2][0]);
res += min(act[0][1], act[1][0]);
b = abs(act[0][1] - act[1][0]);
res += min(act[1][2], act[2][1]);
c = abs(act[1][2] - act[2][1]);
if (a == b && b == c) res += a*2;
else return -1;
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... |