Submission #653996

#TimeUsernameProblemLanguageResultExecution timeMemory
653996BlagojMutating DNA (IOI21_dna)C++17
0 / 100
307 ms3716 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string a, b; void init(std::string a1, std::string b1) { a = a1; b = b1; } int get_distance(int x, int y) { string c = a; int cnt = 0; bool possible = true, subpossible = false; for (int i = x; i <= y; i++) { if (c[i] != b[i]) { subpossible = false; for (int j = i + 1; j <= y; j++) { if (c[j] == b[i]) { subpossible = true; swap(c[i], c[j]); cnt++; break; } } if (!subpossible) { possible = false; } } } if (!possible) { return -1; } return cnt; }
#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...