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> balance1, balance2, misplacecount;
void init(string a, string b) {
as = a;
bs = b;
int n = a.length();
balance1.resize(n + 2, 0);
balance2.resize(n + 2, 0);
misplacecount.resize(n + 2, 0);
for (int i = 1; i <= n; ++i) {
balance1[i] = balance1[i - 1] + (as[i - 1] == 'A' ? 1 : -1);
balance2[i] = balance2[i - 1] + (bs[i - 1] == 'A' ? 1 : -1);
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 ((balance1[y] - balance2[x]) != (balance2[y] - balance2[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... |