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 as, bs;
vector<int> acount1, acount2, tcount1, tcount2, misplacecount;
void init(string a, string b) {
as = a;
bs = b;
int n = a.length();
acount1.resize(n + 2, 0);
acount2.resize(n + 2, 0);
misplacecount.resize(n + 2, 0);
for (int i = 1; i <= n; ++i) {
acount1[i] = acount1[i - 1] + (as[i - 1] == 'A');
acount2[i] = acount2[i - 1] + (bs[i - 1] == 'A');
tcount1[i] = tcount1[i - 1] + (as[i - 1] == 'T');
tcount2[i] = tcount2[i - 1] + (bs[i - 1] == 'T');
misplacecount[i] =
misplacecount[i - 1] + (as[i - 1] == 'A' && as[i - 1] != bs[i - 1]);
// printf("i : %d, %d %d %d\n", i, acount1[i], acount2[i],
// misplacecount[i]);
}
}
int get_distance(int x, int y) {
if ((acount1[y] - acount1[x]) != (acount2[y] - acount2[x]) || tcount1[y] - tcount1[x] != tcount2[y] - tcount2[x])
return -1;
return misplacecount[y] - misplacecount[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... |