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 s, s2;
int n;
const int N = 1e5 + 5;
int p_a[N] = {0}, p_b[N] = {0}, p_bile[N] = {0};
void init(string a, string b){
s = a;
s2 = b;
n = (int)s.size();
for(int i = 0; i < n; ++i){
p_a[i + 1] = p_a[i];
p_b[i + 1] = p_b[i];
p_bile[i + 1] = p_bile[i];
if(a[i] == 'A')
p_a[i + 1]++;
if(b[i] == 'A')
p_b[i + 1]++;
if(a[i] == b[i])
p_bile[i + 1]++;
}
}
int get_distance(int x, int y){
if(y - x > 2){
int uz_a = p_a[y + 1] - p_a[x], uz_b = p_b[y + 1] - p_b[x];
int uz_bile = p_bile[y + 1] - p_bile[x];
if(uz_a != uz_b)
return -1;
else{
int ret = (y - x + 1 - uz_bile) >> 1;
return ret;
}
}
int s_a = 0, s_c = 0, s_t = 0;
int s2_a = 0, s2_c = 0, s2_t = 0;
for(int i = x; i <= y; ++i){
s_a += (s[i] == 'A');
s_c += (s[i] == 'C');
s_t += (s[i] == 'T');
s2_a += (s2[i] == 'A');
s2_c += (s2[i] == 'C');
s2_t += (s2[i] == 'T');
}
if(s_a != s2_a or s_c != s2_c or s_t != s2_t)
return -1;
int ok = 1;
for(int i = x; i <= y; ++i)
ok &= (s[i] == s2[i]);
if(ok)
return 0;
int ans = 0;
for(int i = x; i <= y; ++i)
ans += (s[i] != s2[i]);
ans--;
return ans;
}
# | 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... |