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 a,b;
int n;
int prefa[100001]={0},prefb[100001]={0},prefm[100001]={0};
void init(string c, string d) {
a=c;b=d;
n=a.size();
for(int i=0;i<n;i++){
prefa[i+1]=prefa[i];
prefb[i+1]=prefb[i];
prefm[i+1]=prefm[i];
if(a[i]=='A')prefa[i+1]++;
if(b[i]=='A')prefb[i+1]++;
if(a[i]==b[i])prefm[i+1]++;
}
}
int get_distance(int x, int y) {
int dista=prefa[y+1]-prefa[x];
int distb=prefb[y+1]-prefb[x];
int distm=prefm[y+1]-prefm[x];
if(dista!=distb)return -1;
else{
return distm/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... |