# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
691497 | ismayil | Mutating DNA (IOI21_dna) | C++17 | 42 ms | 7032 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>
#define ll long long
using namespace std;
const int MAX = 1e5 + 5;
int dp[MAX][3][3];
int n;
void init(string a, string b){
map<char, char> m = {{'A', 0}, {'T', 1}, {'C', 2}};
n = a.size();
for (int i = 0; i < n; i++)
{
a[i] = m[a[i]];
b[i] = m[b[i]];
}
if(a[0] != b[0]) dp[0][a[0]][b[0]]++;
for (int i = 1; i < n; i++)
{
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
dp[i][j][k] = dp[i - 1][j][k];
if(a[i] != b[i]) dp[i][a[i]][b[i]]++;
}
}
int get_distance(int x, int y){
int c[3][3];
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
c[i][j] = dp[y][i][j];
if(x != 0) c[i][j] -= dp[x - 1][i][j];
}
}
int ans = 0;
ans = min(c[0][1], c[1][0]) + min(c[1][2], c[2][1]) + min(c[0][2], c[2][0]);
if((c[0][1] - c[1][0]) == (c[2][0] - c[0][2]) && (c[2][0] - c[0][2]) == (c[1][2] - c[2][1])) return (ans + 2 * abs(c[0][1] - c[1][0]));
return -1;
}
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... |