# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1255795 | robijoy | Mutating DNA (IOI21_dna) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
// #include "dna.h"
using namespace std;
string A,B;
int n;
void init(std::string a, std::string b) {
A = a;
B = b;
n = a.size();
}
int get_distance(int x, int y) {
if(x == y) {
if(A[x]!=B[y]) {
return -1;
}else {
return 0;
}
}
int ans = -1;
string ro = A.substr(x,y-x+1);
string ra = B.substr(x,y-x+1);
string roo = ro;
string raa = ra;
sort(roo.begin(), roo.end());
sort(raa.begin(), raa.end());
if(roo == raa) {
if(ro == ra) {
ans = 0;
}else{
ans = 1;
}
}
return ans;
}
int main() {
init("ATATAT","ATTATA");
cout<<get_distance(0,1)<<endl;
}