# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
981506 | faqinyeager | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 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>
int n, a_cnt, b_cnt;
int asum[100050][3], bsum[100050][3];
string aa, bb;
void init(std::string a, std::string b){
aa = a, bb = b;
n = (int)a.size();
for(int i = 0; i < n; i++){
asum[i][a[i] - 'A'] ++;
bsum[i][b[i] - 'A'] ++;
}
for(int i = 1; i < n; i++){
for(int j = 0; j < 3; j++){
asum[i][j] += asum[i - 1][j];
bsum[i][j] += bsum[i - 1][j];
}
}
}
int get_distance(int x, int y){
for(int j = 0; j < 3; j++){
if(asum[y][j] - asum[x - 1][j] != bsum[y][j] - bsum[x - 1][j]){
return -1;
}
}
int cnt = 0;
for(int i = x; i < y; i++){
if(aa[i] != bb[i]){
cnt++;
}
}
return (cnt + 1) / 2;
}