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(string A, string B) {
a = A;
b = B;
}
int get_distance(int x, int y) {
string A = "", B = "";
if(y - x == 0) {
if(a[x] == b[x])return 0;
return -1;
}
if(y-x == 1) {
if(a[x] == b[x] and a[y] == b[y])return 0;
if(a[y] == b[x] and a[x] == b[y])return 1;
return -1;
}
else {
int c = 0;
set<char> s;
for(int i = x;i<=y;i++) {
s.insert(a[i]);
A.push_back(a[i]);
B.push_back(b[i]);
if(a[i] != b[i])c++;
}
sort(A.begin(), A.end());
sort(B.begin(), B.end());
if(A != B) {
return -1;
}
if(s.size() == 1)return 0;
if(c == 0)return 0;
if(s.size() == 2 and c == 2)return 1;
if(s.size() == 3 and c == 2)return 1;
if(s.size() == 3 and c == 3)return 2;
return 0;
}
}
# | 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... |