# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930438 | SmuggingSpun | Mutating DNA (IOI21_dna) | C++17 | 34 ms | 7192 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;
const int lim = 1e5 + 5;
int get_id(char c){
return (c == 'A' ? 0 : 1 + int(c == 'T'));
}
int cnt[lim][3][3];
void init(string a, string b){
int n = a.size();
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
cnt[0][i][j] = 0;
}
}
for(int i = 1; i <= n; i++){
for(int j = 0; j < 3; j++){
for(int k = 0; k < 3; k++){
cnt[i][j][k] = cnt[i - 1][j][k] + int(get_id(a[i - 1]) == j && get_id(b[i - 1]) == k);
}
}
}
}
int get_distance(int x, int y) {
x++;
y++;
int cycle, ans = 0;
for(int i = 0; i < 3; i++){
int j = (i == 2 ? 0 : i + 1), a = cnt[y][i][j] - cnt[x - 1][i][j], b = cnt[y][j][i] - cnt[x - 1][j][i];
if(i == 0){
cycle = a - b;
}
else if(cycle != a -b){
return -1;
}
ans += min(a, b);
}
return ans + (abs(cycle) << 1);
}
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... |