# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
712499 | Kripton | Mutating DNA (IOI21_dna) | C++17 | 35 ms | 6584 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 <bits/stdc++.h>
#include "dna.h"
using namespace std;
int a1[100001], a2[100001];
int c1[100001], c2[100001];
int t1[100001], t2[100001];
int diff[100001];
void init(string a, string b)
{
for(int i = 1; i <= a.size(); i++)
{
c1[i] = c1[i - 1] + (a[i - 1] == 'C');
a1[i] = a1[i - 1] + (a[i - 1] == 'A');
t1[i] = t1[i - 1] + (a[i - 1] == 'T');
c2[i] = c2[i - 1] + (b[i - 1] == 'C');
a2[i] = a2[i - 1] + (b[i - 1] == 'A');
t2[i] = t2[i - 1] + (b[i - 1] == 'T');
diff[i] = diff[i - 1] + (a[i - 1] != b[i - 1]);
}
}
int get_distance(int x, int y)
{
x++;
y++;
if(c1[y] - c1[x - 1] != c2[y] - c2[x - 1])
return -1;
if(a1[y] - a1[x - 1] != a2[y] - a2[x - 1])
return -1;
if(t1[y] - t1[x - 1] != t2[y] - t2[x - 1])
return -1;
return (diff[y] - diff[x - 1] + 1) / 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... |