Submission #1142023

#TimeUsernameProblemLanguageResultExecution timeMemory
1142023mehdibaDNA 돌연변이 (IOI21_dna)C++20
0 / 100
1602 ms916236 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...