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;
#define ff first
#define ss second
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];
// cout << a << " " << b << "\n";
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;
int answer = 0;
for(int i = 0; i < n; ++i){
if(a[i] == b[i])
continue;
for(int j = i+1; j < n; ++j)
if(a[j] == b[i] and a[i] == b[j] and a[i] != a[j]){
answer++;
swap(a[i], a[j]);
}
}
for(int i = 0; i < n; ++i){
if(a[i] == b[i])
continue;
for(int j = i+1; j < n; ++j)
if(a[j] == b[i] and a[i] != a[j]){
answer++;
swap(a[i], a[j]);
}
}
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... |