# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
914657 | JooDdae | Mutating DNA (IOI21_dna) | C++17 | 42 ms | 7488 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;
using ll = long long;
int r[256], n, s[100100][3][3], c[3][3], p[3];
void init(string a, string b) {
r['A'] = 0, r['T'] = 1, r['C'] = 2;
n = a.size();
for(int i=0;i<n;i++) {
int A = r[a[i]], B = r[b[i]];
for(int j=0;j<3;j++) for(int k=0;k<3;k++) s[i+1][j][k] = s[i][j][k] + (j == A && k == B);
}
}
int get_distance(int x, int y) {
for(int i=0;i<3;i++) for(int j=0;j<3;j++) c[i][j] = s[y+1][i][j] - s[x][i][j];
p[0] = p[1] = p[2] = 0;
for(int i=0;i<3;i++) for(int j=0;j<3;j++) p[i] += c[i][j], p[j] -= c[i][j];
if(p[0] || p[1] || p[2]) return -1;
int ans = 0;
for(int i=0;i<3;i++) for(int j=i+1;j<3;j++) {
int k = min(c[i][j], c[j][i]);
ans += k, c[i][j] -= k, c[j][i] -= k;
}
return ans + c[0][1]*2 + c[1][0]*2;
}
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... |