# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
716239 | kidlin | Mutating DNA (IOI21_dna) | C++17 | 1580 ms | 3828 KiB |
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 s, t;
void init(std::string a, std::string b)
{
s = a;
t = b;
}
int get_distance(int x, int y)
{
string s1 = s.substr(x, y - x + 1);
string t1 = t.substr(x, y - x + 1);
int ans = 0;
for (int i = 0; i < t1.size(); i ++)
{
if (s1[i] == t1[i])
continue;
bool done = false;
for (int j = i; j < t1.size(); j ++)
{
if (s1[j] == t1[i] && t1[j] == s1[i])
{
swap(s1[j], s1[i]);
ans ++;
done = true;
break;
}
}
if (!done)
{
for (int j = i; j < t1.size(); j ++)
{
if (s1[j] == t1[i] && s1[j] != t1[j])
{
swap(s1[j], s1[i]);
ans ++;
done = true;
break;
}
}
}
///cout << i << " : " << j << endl;
if (!done)
return -1;
}
return ans;
}
Compilation message (stderr)
# | 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... |