# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1009551 | somefjord | Mutating DNA (IOI21_dna) | C++17 | 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 "dna.h"
#include <bits/stdc++.h>
using namespace std;
string as, bs;
vector<int> mc1, mc2;
void init(string a, string b) {
as = a;
bs = b;
int n = a.length();
mc1.resize(n + 2, 0);
mc2.resize(n + 2, 0);
for (int i = 1; i <= n; ++i) {
mc1[i] = mc1[i - 1] + (as[i - 1] == 'A' && as[i - 1] != bs[i - 1]);
mc2[i] = mc2[i - 1] + (bs[i - 1] == 'T' && as[i - 1] != bs[i - 1]);
// printf("i : %d, %d %d %d\n", i, acount1[i], acount2[i],
// mc[i]);
}
}
int get_distance(int x, int y) {
int c1 = mc1[y] - mc1[x];
int c2 = mc2[y] - mc2[x];
if (c1 != c2)
return -1;
return c1;