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 <cstdio>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> ta, aa, ca, tb, ab, cb, same;
void init(string a, string b){
int n = a.size();
ta.resize(n + 1);
aa.resize(n + 1);
ca.resize(n + 1);
tb.resize(n + 1);
ab.resize(n + 1);
cb.resize(n + 1);
same.resize(n + 1);
for (int i = 1; i <= n; i++){
ta[i] = ta[i-1] + (a[i-1] == 'T');
aa[i] = aa[i-1] + (a[i-1] == 'A');
ca[i] = ca[i-1] + (a[i-1] == 'C');
tb[i] = tb[i-1] + (b[i-1] == 'T');
ab[i] = ab[i-1] + (b[i-1] == 'A');
cb[i] = cb[i-1] + (b[i-1] == 'C');
same[i] = same[i-1] + (a[i-1] == b[i-1]);
}
}
int get_distance(int x, int y){
if (ta[y+1] - ta[x] != tb[y+1] - tb[x] || aa[y+1] - aa[x] != ab[y+1] - ab[x] || ca[y+1] - ca[x] != cb[y+1] - cb[x]) return -1;
return (y - x) - (same[y+1] - same[x]);
}
# | 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... |