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 fi first
#define se second
#define m_p make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
const int N = 100005;
int n;
int p[N][3][3];
void init(std::string a, std::string b) {
n = sz(a);
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < 3; ++j)
{
for (int k = 0; k < 3; ++k)
{
p[i + 1][j][k] = p[i][j][k];
}
}
int aa, bb;
if (a[i] == 'A')
aa = 0;
else if (a[i] == 'T')
aa = 1;
else
aa = 2;
if (b[i] == 'A')
bb = 0;
else if (b[i] == 'T')
bb = 1;
else
bb = 2;
++p[i + 1][aa][bb];
}
}
int get_distance(int l, int r) {
++l;
++r;
int q[3][3];
for (int j = 0; j < 3; ++j)
{
for (int k = 0; k < 3; ++k)
{
q[j][k] = p[r][j][k] - p[l - 1][j][k];
}
}
int ans = 0;
for (int j = 0; j < 3; ++j)
q[j][j] = 0;
for (int j = 0; j < 3; ++j)
{
for (int k = 0; k < 3; ++k)
{
int minu = min(q[j][k], q[k][j]);
ans += minu;
q[j][k] -= minu;
q[k][j] -= minu;
}
}
for (int j = 0; j < 3; ++j)
{
for (int k = 0; k < 3; ++k)
{
for (int i = 0; i < 3; ++i)
{
int minu = min(q[i][j], min(q[j][k], q[k][i]));
ans += minu * 2;
q[i][j] -= minu;
q[j][k] -= minu;
q[k][i] -= minu;
}
}
}
for (int j = 0; j < 3; ++j)
{
for (int k = 0; k < 3; ++k)
{
if (q[j][k])
return -1;
}
}
return ans;
}
# | 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... |