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