# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1142119 | samia | Mutating DNA (IOI21_dna) | C++20 | 0 ms | 0 KiB |
#include "dna.h"
#include<bits/stdc++.h>
using namespace std;
string A,B;
void init(string a, string b) {
A=a;
m['A']=0;
m['B']=0;
B=b;
}
int get_distance(int x, int y) {
int ans;
map<char,int>m;
map<char,int>m1;
int f[A.size()];
f[0]=0;
for(int so=0;so<A.size();so++){f[so]=0;}
for(int so=0;so<A.size();so++){
m[A[so]]+=1;
m1[B[so]]+=1;
if(so!=0){f[so]=f[so-1];}
if(A[so]!=B[so]){f[so]+=1;}
}
if(m['A']==m1['A']&&m['T']==m1['T']){ return f[y]-f[x];}
else {return -1;}
}