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;
int n;
vector<vector<int>>c1,c2;
vector<int>dp;
void init(std::string a, std::string b) {
n=a.size();
dp.resize(n+1);
dp[0]=0;
c1.assign(n+1,vector<int>(26,0));
c2=c1;
for(int i=0;i<n;i++){
dp[i+1]=dp[i]+(a[i]==b[i]);
// cout<<dp[i+1]<<' ';
c1[i+1]=c1[i];
c1[i+1][a[i]-'A']++;
c2[i+1]=c2[i];
c2[i+1][b[i]-'A']++;
}
}
int get_distance(int x, int y) {
for(int i=0;i<26;i++) if(c1[y+1][i]-c1[x][i]!=c2[y+1][i]-c2[x][i]) return -1;
return ((y-x+1)-dp[y+1]+dp[x]+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... |