# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
811161 | math_rabbit_1028 | Mutating DNA (IOI21_dna) | C++17 | 29 ms | 6356 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 "dna.h"
#include <bits/stdc++.h>
using namespace std;
int cnt[101010][3], dif[101010][6];
void init(std::string a, std::string b) {
for (int i = 0; i < a.length(); i++) {
cnt[i + 1][0] = cnt[i][0];
cnt[i + 1][1] = cnt[i][1];
cnt[i + 1][2] = cnt[i][2];
if (a[i] == 'A') cnt[i + 1][0]++;
if (a[i] == 'C') cnt[i + 1][1]++;
if (a[i] == 'T') cnt[i + 1][2]++;
if (b[i] == 'A') cnt[i + 1][0]--;
if (b[i] == 'C') cnt[i + 1][1]--;
if (b[i] == 'T') cnt[i + 1][2]--;
dif[i + 1][0] = dif[i][0];
dif[i + 1][1] = dif[i][1];
dif[i + 1][2] = dif[i][2];
dif[i + 1][3] = dif[i][3];
dif[i + 1][4] = dif[i][4];
dif[i + 1][5] = dif[i][5];
if (a[i] == 'A' && b[i] == 'C') dif[i + 1][0]++;
if (a[i] == 'A' && b[i] == 'T') dif[i + 1][1]++;
if (a[i] == 'C' && b[i] == 'A') dif[i + 1][2]++;
if (a[i] == 'C' && b[i] == 'G') dif[i + 1][3]++;
if (a[i] == 'T' && b[i] == 'A') dif[i + 1][4]++;
if (a[i] == 'T' && b[i] == 'C') dif[i + 1][5]++;
}
}
int get_distance(int x, int y) {
if (cnt[x][0] != cnt[y + 1][0]) return -1;
if (cnt[x][1] != cnt[y + 1][1]) return -1;
if (cnt[x][2] != cnt[y + 1][2]) return -1;
int ans = 0;
ans += min(dif[y + 1][0] - dif[x][0], dif[y + 1][2] - dif[x][2]);
ans += min(dif[y + 1][1] - dif[x][1], dif[y + 1][4] - dif[x][4]);
ans += min(dif[y + 1][3] - dif[x][3], dif[y + 1][5] - dif[x][5]);
ans += 2 * abs(dif[y + 1][0] - dif[x][0] - dif[y + 1][2] + dif[x][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... |