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;
const int maxn=1e5;
int pre[maxn+1][3][3];
void init(std::string a, std::string b) {
map<char,int> m;
m['A']=0;
m['T']=1;
m['C']=2;
int n=a.length();
for(int i=1;i<=n;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
pre[i][j][k]=pre[i-1][j][k];
}
}
pre[i][m[a[i-1]]][m[b[i-1]]]++;
}
}
int get_distance(int x, int y) {
int cnt[3][3],c[3]={0,0,0};
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cnt[i][j]=pre[y+1][i][j]-pre[x][i][j];
c[i]+=cnt[i][j];
c[j]-=cnt[i][j];
}
}
for(int i=0;i<3;i++){
if(c[i])return -1;
}
return (cnt[0][1]+cnt[1][0])/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... |