# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484439 | Spade1 | Mutating DNA (IOI21_dna) | C++17 | 35 ms | 6212 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"
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define pb push_back
using namespace std;
int p[100010][6];
void init(string a, string b) {
for (int i = 1; i <= a.size(); ++i) {
if (a[i - 1] == 'A' && b[i - 1] == 'C') p[i][0]++;
if (a[i - 1] == 'A' && b[i - 1] == 'T') p[i][1]++;
if (a[i - 1] == 'C' && b[i - 1] == 'A') p[i][2]++;
if (a[i - 1] == 'C' && b[i - 1] == 'T') p[i][3]++;
if (a[i - 1] == 'T' && b[i - 1] == 'A') p[i][4]++;
if (a[i - 1] == 'T' && b[i - 1] == 'C') p[i][5]++;
for (int j = 0; j < 6; ++j) p[i][j] += p[i - 1][j];
}
}
int get_distance(int x, int y) {
++x, ++y;
int tmp[6];
for (int i = 0; i < 6; ++i) {
tmp[i] = p[y][i] - p[x - 1][i];
}
int A1 = tmp[0] + tmp[1], A2 = tmp[2] + tmp[4];
int C1 = tmp[2] + tmp[3], C2 = tmp[0] + tmp[5];
int T1 = tmp[4] + tmp[5], T2 = tmp[1] + tmp[3];
if (A1 != A2 || C1 != C2 || T1 != T2) return -1;
int ans1 = 0;
for (int i = 0; i < 6; ++i) ans1 += tmp[i];
int ans2 = min(tmp[0], tmp[2]) + min(tmp[1], tmp[4]) + min(tmp[3], tmp[5]);
ans1 -= 2*ans2;
ans1 = ans1/3*2;
return ans1 + ans2;
}
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... |