# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
768563 | Trumling | Split the Attractions (IOI19_split) | C++14 | 0 ms | 0 KiB |
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 <vector>
#include <string>
using namespace std;
vector<int> mutationCount;
void init(string a, string b) {
int n = a.length();
mutationCount.resize(n + 1, 0);
for (int i = 0; i < n; i++) {
mutationCount[i + 1] = mutationCount[i] + (a[i] != b[i]);
}
}
int get_distance(int x, int y) {
int mutationInRange = mutationCount[y + 1] - mutationCount[x];
int substringLength = y - x + 1;
if (mutationInRange == 0 || mutationInRange == substringLength) {
return mutationInRange / 2;
} else {
return -1;
}
}