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;
const int N = 1e5+5;
int a_s[N], c_s[N], t_s[N], a_s2[N], c_s2[N], t_s2[N], diff[N];
void init(string a, string b){
int n = (int)a.size();
for(int i = 0; i < n; ++i){
diff[i+1] = diff[i] + (a[i] != b[i]);
a_s[i+1] = a_s[i] + (a[i] == 'A');
c_s[i+1] = c_s[i] + (a[i] == 'C');
t_s[i+1] = t_s[i] + (a[i] == 'T');
a_s2[i+1] = a_s2[i] + (b[i] == 'A');
c_s2[i+1] = c_s2[i] + (b[i] == 'C');
t_s2[i+1] = t_s2[i] + (b[i] == 'T');
}
}
int get_distance(int x, int y){
int sm = a_s[y+1]-a_s[x];
// sm = a[x...y] 'A'-laryn sany
sm -= (a_s2[y+1]-a_s2[x]);
int sm2 = c_s[y+1]-c_s[x];
sm2 -= (c_s2[y+1]-c_s2[x]);
int sm3 = t_s[y+1]-t_s[x];
sm3 -= (t_s2[y+1]-t_s2[x]);
if(sm or sm2 or sm3)
return -1;
int answer = diff[y+1]-diff[x]+1;
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... |