# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1142633 | younesb13 | Mutating DNA (IOI21_dna) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "dna.h"
using namespace std;
string A;
string dna_b;
void init(string a, string b) {
A=a;
A=b;
return;
}
int get_distance(int y, int x) {
int a=0;
int t=0;
int r=0;
for (int i=y;i<x+1;i++) {
if(A[i]=='A') {
a++;
}
if(B[i]=='A') {
a--;
}
if(A[i]=='T') {
t++;
}
if(B[i]=='T') {
t--;
}
if(A[i]!=B[i]) {
r++;
}
}
if (a==0 && t==0) {
return r/2+r%2;
}
else {
return -1;
}
}