# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
437161 | flashmt | Mutating DNA (IOI21_dna) | C++17 | 69 ms | 8452 KiB |
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>
using namespace std;
int n, cntA[3][100100], cntB[3][100100], cntAB[3][3][100100];
void init(string a, string b)
{
int m[256];
m['A'] = 0;
m['C'] = 1;
m['T'] = 2;
n = a.size();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 3; j++)
{
cntA[j][i + 1] = cntA[j][i];
cntB[j][i + 1] = cntB[j][i];
for (int k = 0; k < 3; k++)
cntAB[j][k][i + 1] = cntAB[j][k][i];
}
cntA[m[a[i]]][i + 1]++;
cntB[m[b[i]]][i + 1]++;
cntAB[m[a[i]]][m[b[i]]][i + 1]++;
}
}
int get_distance(int x, int y) {
y++;
for (int i = 0; i < 3; i++)
if (cntA[i][y] - cntA[i][x] != cntB[i][y] - cntB[i][x])
return -1;
int ans = 0, share = 0;
for (int i = 0; i < 3; i++)
for (int j = i + 1; j < 3; j++)
{
int u = cntAB[i][j][y] - cntAB[i][j][x];
int v = cntAB[j][i][y] - cntAB[j][i][x];
ans += min(u, v);
share += abs(u - v);
}
assert(share % 3 == 0);
ans += share / 3 * 2;
return ans;
}
Compilation message (stderr)
# | 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... |