This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dna.h"
#include <iostream>
std::string A, B;
void init(std::string a, std::string b)
{
A = a;
B = b;
}
int get_distance(int x, int y)
{
std::string a, b;
for (int i = x; i <= y; ++i)
a.push_back(A[i]),
b.push_back(B[i]);
if (a == b)
return 0;
for (int i = x; i <= y; ++i)
for (int j = i+1 ; j <= y; ++j)
{
std::swap(a[i], a[j]);
if (a == b)
return 1;
std::swap(a[j], a[i]);
}
for (int i = 0; i <= y - x; ++i)
for (int j = i + 1; j <= y - x; ++j)
for (int l = 0; l <= y - x; ++l)
for (int k = l+1; k <= y - x; ++k)
{
std::swap(a[i], a[j]);
std::swap(a[l], a[k]);
if (a == b)
return 2;
std::swap(a[k], a[l]);
std::swap(a[j], a[i]);
}
return -1;
}
# | 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... |