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"dna.h"
using namespace std;
//#define int long long
const int N = 2e5 + 1;
int p[N] , A[N][3][2];
void init(string a , string b){
for(int i = 0;i < (int)a.size();i ++){
p[i] = 0;
for(int k = 0;k < 3;k ++){
for(int m = 0;m < 2;m ++){
A[i][k][m] = 0;
}
}
}
map<char , int> to;
to['A'] = 1 , to['C'] = 2 , to['T'] = 0;
for(int i = 0;i < (int)a.size();i ++){
if(i){
p[i] = p[i - 1];
for(int k = 0;k < 3;k ++){
for(int m = 0;m < 2;m ++){
A[i][k][m] = A[i - 1][k][m];
}
}
}
p[i] += (a[i] != b[i]);
A[i][to[a[i]]][0]++;
A[i][to[b[i]]][1]++;
}
}
int get_distance(int x , int y){
for(int k = 0;k < 3;k ++){
int a = A[y][k][0] - (x ? A[x - 1][k][0] : 0), b = A[y][k][1] - (x ? A[x - 1][k][1] : 0);
if(a != b) return -1;
}
return (p[y] - p[x - 1] + 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... |