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;
string s3, s4;
void init(string s, string s2){
s3 = s, s4 = s2;
}
int get_distance(int x, int y){
string a = "", b = "";
for(int i = x; i <= y; ++i)
a += s3[i], b += s4[i];
int n = (int)a.size();
int sm = 0, sm2 = 0, sm3 = 0;
for(int i = 0; i < n; ++i){
if(a[i] == 'A')
sm++;
if(b[i] == 'A')
sm--;
if(a[i] == 'C')
sm2++;
if(b[i] == 'C')
sm2--;
if(a[i] == 'T')
sm3++;
if(b[i] == 'T')
sm3--;
}
if(sm or sm2 or sm3)
return -1;
// O(q*m^2)
int answer = 0;
for(int i = 0; i < n; ++i){
char c = a[i], c2 = b[i];
if(c == c2)
continue;
for(int j = i+1; j < n; ++j)
if(a[j] == c2 and b[j] == c){
answer++;
swap(a[i], a[j]);
}
}
for(int i = 0; i < n; ++i)
if(a[i] != b[i])
answer += 2;
return answer;
}
# | 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... |