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>
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <set>
//#include "dna.h"
#include <cstdio>
#include <cassert>
#include <string>
using namespace std;
string A;
string B;
void init(string a,string b){
A = a;
B = b;
}
int get_distance(int x, int y) {
vector<int> v(6, 0);
for (int i = x; i <= y; i++) {
if (A[i] != B[i]) {
if (A[i] == 'A') {
if (B[i] == 'T') v[0]++; // A-T imbalance
if (B[i] == 'C') v[1]++; // A-C imbalance
} else if (A[i] == 'C') {
if (B[i] == 'A') v[2]++; // C-A imbalance
if (B[i] == 'T') v[3]++; // C-T imbalance
} else {
if (B[i] == 'A') v[4]++; // T-A imbalance
if (B[i] == 'C') v[5]++; // T-C imbalance
}
}
}
if (v[0] + v[1] == v[2] + v[3] && v[0] + v[1] == v[4] + v[5]) {
int res = 0;
res += min(v[0], v[4]);
res += min(v[1], v[2]);
res += min(v[3], v[5]);
res += 2 * abs(v[0] - v[4]); // Corrected calculation
return res;
} else {
return -1;
}
}
# | 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... |