# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
712498 | Kripton | Mutating DNA (IOI21_dna) | C++17 | 33 ms | 6284 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>
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 = 0; i < a.size(); i++)
{
c1[i] = c1[i - 1] + (a[i] == 'c');
a1[i] = a1[i - 1] + (a[i] == 'a');
t1[i] = t1[i - 1] + (a[i] == 't');
c2[i] = c2[i - 1] + (b[i] == 'c');
a2[i] = a2[i - 1] + (b[i] == 'a');
t2[i] = t2[i - 1] + (b[i] == 't');
diff[i] = diff[i - 1] + (a[i] != b[i]);
}
}
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]) / 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... |