# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443408 | Aryan_Raina | Mutating DNA (IOI21_dna) | C++17 | 54 ms | 9404 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;
#define ar array
#define all(a) a.begin(), a.end()
int id(char x) {
if (x == 'A') return 0;
else if (x == 'C') return 1;
else if (x == 'T') return 2;
return -1;
}
const int MXN = 100009;
int cnt[MXN][3][3], tota[MXN][3], totb[MXN][3];
void init(string a, string b) {
for (int i = 0; i < a.size(); i++) {
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
cnt[i+1][j][k] = cnt[i][j][k];
cnt[i+1][id(a[i])][id(b[i])]++;
for (int j = 0; j < 3; j++) {
tota[i+1][j] = tota[i][j];
totb[i+1][j] = totb[i][j];
}
tota[i+1][id(a[i])]++;
totb[i+1][id(b[i])]++;
}
}
int get_distance(int x, int y) {
++x, ++y;
for (int i = 0; i < 3; i++)
if (tota[y][i]-tota[x-1][i] != totb[y][i]-totb[x-1][i])
return -1;
int A[3][3];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
A[i][j] = cnt[y][i][j]-cnt[x-1][i][j];
int ans = 0;
ans += min(A[0][1],A[1][0]);
ans += min(A[1][2],A[2][1]);
ans += min(A[2][0],A[0][2]);
ans += 2 * (max(A[0][1],A[1][0])-min(A[0][1],A[1][0]));
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... |