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>
#include <vector>
using namespace std;
int sum[300000];
int suma[3][300000], sumb[3][300000];
const string dna = "ATC";
void init(std::string a, std::string b) {
memset(sum, 0, sizeof(sum));
memset(suma, 0, sizeof(suma));
memset(suma, 0, sizeof(sumb));
for (int i = 0; i < (int)a.size(); ++i) {
sum[i + 1] = sum[i] + (a[i] != b[i]);
}
for (int j = 0; j < 3; ++j) {
for (int i = 0; i < (int)a.size(); ++i) {
suma[j][i + 1] = suma[j][i] + (a[i] == dna[j]);
sumb[j][i + 1] = sumb[j][i] + (b[i] == dna[j]);
}
}
}
int get_distance(int x, int y) {
++y;
for (int i = 0; i < 3; ++i) {
if (suma[i][y] - suma[i][x] != sumb[i][y] - sumb[i][x]) {
return -1;
}
}
return (sum[y] - sum[x] + 1) / 2;
}
# | 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... |