# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442791 | baluteshih | Mutating DNA (IOI21_dna) | C++17 | 50 ms | 6528 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define SZ(a) ((int)a.size())
int num[256];
int prea[3][100005], preb[3][100005], same[100005];
int get_sum(int *arr, int l, int r) {
if (l == 0)
return arr[r];
return arr[r] - arr[l - 1];
}
void init(string a, string b) {
int n = SZ(a);
num['A'] = 0, num['T'] = 1, num['C'] = 2;
for (int i = 0; i < n; ++i) {
++prea[num[a[i]]][i];
++preb[num[b[i]]][i];
same[i] = (a[i] == b[i]);
}
for (int i = 1; i < n; ++i) {
prea[0][i] += prea[0][i - 1];
prea[1][i] += prea[1][i - 1];
prea[2][i] += prea[2][i - 1];
preb[0][i] += preb[0][i - 1];
preb[1][i] += preb[1][i - 1];
preb[2][i] += preb[2][i - 1];
same[i] += same[i - 1];
}
}
int get_distance(int x, int y) {
if (get_sum(prea[0], x, y) != get_sum(preb[0], x, y))
return -1;
if (get_sum(prea[1], x, y) != get_sum(preb[1], x, y))
return -1;
if (get_sum(prea[2], x, y) != get_sum(preb[2], x, y))
return -1;
return (y - x + 1 - get_sum(same, x, y)) / 2;
}
Compilation message (stderr)
# | 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... |