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 <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 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... |