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 <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include "dna.h"
using namespace std;
const int maxn = 1e5 + 5;
int a_pref_sum[maxn][4];
int b_pref_sum[maxn][4];
string a, b;
int n;
void init(string a, string b) {
memset(a_pref_sum, 0, sizeof a_pref_sum);
memset(b_pref_sum, 0, sizeof b_pref_sum);
n = (int) a.size();
for(int i = 0; i < n; i++) {
if(a[i] == 'C') a[i] = 'B';
if(b[i] == 'C') b[i] = 'B';
}
for(int i = 0; i < n; i++) {
if(a[i] == 'T') a[i] = 'C';
if(b[i] == 'T') b[i] = 'C';
}
::a = a;
::b = b;
}
int get_distance(int x, int y) {
vector<int> c_a(3, 0), c_b(3, 0);
for(int i = x; i <= y; i++) {
c_a[a[i] - 'A']++;
c_b[b[i] - 'A']++;
}
if(c_a[0] != c_b[0] or c_a[1] != c_b[1] or c_a[2] != c_b[2]) {
return -1;
}
int diff = 0;
for(int i = x; i <= y; i++) {
if(a[i] != b[i]) {
++diff;
}
}
return (diff + 1) / 2;
}
# | 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... |