#include "dna.h"
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
string a, b;
unordered_map<string, bool> vis;
int dfs(string x, string t, int cnt){
if(vis[x]) return -1;
vis[x] = 1;
if(x == t) return cnt;
string t1 = x, t2 = x, t3 = x;
swap(t1[0], t1[1]);
int c1 = dfs(t1, t, cnt + 1);
swap(t2[0], t2[2]);
int c2 = dfs(t2, t, cnt + 1);
swap(t3[1], t3[2]);
int c3 = dfs(t3, t, cnt + 1);
if(c1 == -1 && c2 == -1 && c3 == -1) return -1;
return max(c1, max(c2, c3));
}
void init(string A, string B){
a = A;
b = B;
}
int get_distance(int x, int y){
string aa = a.substr(x, y), bb = b.substr(x, y);
return dfs(aa, bb, 0);
}
# | 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... |