# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930426 | SmuggingSpun | Mutating DNA (IOI21_dna) | C++17 | 23 ms | 4884 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 A[lim], T[lim], C[lim], _A[lim], _T[lim], _C[lim];
void init(string a, string b){
for(int i = A[0] = T[0] = C[0] = 0; i < a.size(); i++){
A[i + 1] = A[i];
T[i + 1] = T[i];
C[i + 1] = C[i];
_A[i + 1] = _A[i];
_T[i + 1] = _T[i];
_C[i + 1] = _C[i];
if(a[i] != b[i]){
if(a[i] == 'A'){
A[i + 1]++;
}
else if(a[i] == 'T'){
T[i + 1]++;
}
else{
C[i + 1]++;
}
if(b[i] == 'A'){
_A[i + 1]++;
}
else if(b[i] == 'T'){
_T[i + 1]++;
}
else{
_C[i + 1]++;
}
}
}
}
int get_distance(int x, int y) {
x++;
y++;
int count_a = A[y] - A[x - 1], count_t = T[y] - T[x - 1], count_c = C[y] - C[x - 1];
if(count_a == _A[y] - _A[x - 1] && count_t == _T[y] - T[x - 1] && count_c == _C[y] - _C[x - 1]){
int cnt = min({count_a, count_t, count_c});
return (cnt << 1) + (((count_a + count_t + count_c) - 3 * cnt) >> 1);
}
return -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... |