제출 #996778

#제출 시각아이디문제언어결과실행 시간메모리
996778overwatch9DNA 돌연변이 (IOI21_dna)C++17
0 / 100
22 ms2392 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; using ll = long long; string A, B; void init(std::string a, std::string b) { A = a; B = b; } int get_distance(int x, int y) { string a = A.substr(x, y - x + 1); string b = B.substr(x, y - x + 1); sort(a.begin(), a.end()); sort(b.begin(), b.end()); if (a != b) return -1; if (y - x + 1 == 1) return 0; a = A.substr(x, y - x + 1); b = B.substr(x, y - x + 1); if (a == b) return 0; if (y - x + 1 == 2) return 1; ll ans = 0; while (a != b) { for (int i = 0; i < 3; i++) { if (a[i] == b[i]) continue; for (int j = 0; j < 3; j++) { if (i == j) continue; if (b[j] == a[i]) { ans += abs(i - j); swap(b[i], b[j]); } } } } return ans; }
#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...