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;
int cnt[2][3][100100], ans[100100];
map<char, int> mp;
void init(string a, string b)
{
n = a.length();
mp['A'] = 0;
mp['C'] = 1;
mp['T'] = 2;
cnt[0][mp[a[0]]][1]++;
cnt[1][mp[b[0]]][1]++;
ans[1] = (a[0] == b[0]) ? 0 : 1;
for(int i=2 ; i<=n ; i++)
{
cnt[0][mp[a[i-1]]][i]++;
cnt[1][mp[b[i-1]]][i]++;
for(int j=0 ; j<3 ; j++)
{
cnt[0][j][i] += cnt[0][j][i-1];
cnt[1][j][i] += cnt[1][j][i-1];
}
ans[i] = ans[i-1] + ((a[i-1] == b[i-1]) ? 0 : 1);
}
}
int get_distance(int x, int y)
{
x++, y++;
for(int j=0 ; j<3 ; j++) if(cnt[0][j][y]-cnt[0][j][x-1] != cnt[1][j][y]-cnt[1][j][x-1]) return -1;
return ((ans[y] - ans[x-1])/2 + (ans[y] - ans[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... |