Submission #653997

#TimeUsernameProblemLanguageResultExecution timeMemory
653997BlagojMutating DNA (IOI21_dna)C++17
43 / 100
1564 ms3772 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; for (int i = x; i <= y; i++) { if (c[i] != b[i]) { for (int j = i + 1; j <= y; j++) { if ((c[j] == b[i] && c[j] != b[j]) || (c[j] == b[i] && c[i] == b[j])) { swap(c[i], c[j]); cnt++; break; } } if (c[i] != b[i]) { for (int j = i + 1; j <= y; j++) { if (c[j] == b[i] && c[j] != b[j]) { swap(c[i], c[j]); cnt++; break; } } } if (c[i] != b[i]) { possible = false; break; } } } 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...