# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1015916 | deera | Mutating DNA (IOI21_dna) | C++17 | 1565 ms | 3932 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 <bits/stdc++.h>
using namespace std;
#include "dna.h"
string A, B;
void init(string a, string b) {
A = a;
B = b;
}
string sorted(string x) {
sort(x.begin(), x.end());
return x;
}
int get_distance(int x, int y) {
string a = A.substr(x, (y-x+1));
string b = B.substr(x, (y-x+1));
if (a == b) {
return 0;
}
if (sorted(a) != sorted(b)) {
return -1;
}
string fa = "", fb = "";
for(int i=0;i<a.size();i++) {
if (a[i] != b[i]) {
fa += a.substr(i, 1);
fb += b.substr(i, 1);
}
}
a = fa;
b = fb;
int n = a.size();
if (a == b) {
return 0;
}
if (n == 1) {
return -1;
}
if (n == 2 || n == 3) {
return n - 1;
}
return (n / 2) + (n % 2);
}
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... |