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;
const int mxN = 100005;
string s, t;
void init(string a, string b) {
s = a, t = b;
}
int not_fixed(string a, string b) {
int ans = 0;
for(int i = 0; i < int(a.length()); i++) {
if(a[i] != b[i])
ans++;
}
return ans;
}
int ceil(int a, int b) {
return a%b == 0 ? a/b : a/b+1;
}
int get_distance(int x, int y) {
string a = s.substr(x, y-x+1), b = t.substr(x, y-x+1);
string a1 = s.substr(x, y-x+1), b1 = t.substr(x, y-x+1);
sort(a1.begin(), a1.end());
sort(b1.begin(), b1.end());
if(a1 != b1)
return -1;
if(x == y) {
if(a == b)
return 0;
return -1;
} else if(x+1 == y) {
if(a == b)
return 0;
swap(a[0], a[1]);
if(a == b)
return 1;
return -1;
} else {
if(a == b)
return 0;
return ceil(not_fixed(a, b), 2);
}
assert(true);
}
# | 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... |