# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
936100 | AtabayRajabli | Mutating DNA (IOI21_dna) | C++17 | 27 ms | 5040 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>
#include "dna.h"
using namespace std;
int n;
int p[7][1000005];
string ax = " ACATCT";
string bx = " CATATC";
void init(string a, string b)
{
n = a.size();
a = ' ' + a;
b = ' ' + b;
for(int i = 1; i <= n; i++)
{
if(a[i] == b[i])continue;
for(int j = 1; j <= 6; j++)
{
if(a[i] == ax[j] && b[i] == b[j])p[j][i]++;
p[j][i] += p[j][i - 1];
}
}
}
int get_distance(int x, int y)
{
++x, ++y;
int s[7] = {0};
for(int i = 1; i <= 6; i++)
{
s[i] = p[i][y] - p[i][x - 1];
}
int ans = 0;
int sx[4] = {0}, j = 1;
for(int i = 1; i < 6; i += 2, j++)
{
if(s[i] != s[i + 1])return -1;
ans += s[i];
sx[j] += s[i];
}
sort(sx + 1, sx + 1 + 3);
cout << ans + sx[1] + min(sx[2], sx[3]);
}
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... |