# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441336 | SirCovidThe19th | Mutating DNA (IOI21_dna) | C++17 | 52 ms | 6592 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 pre[100005][3][3], mp[256];
void init(string a, string b){
mp['A'] = 0, mp['C'] = 1, mp['T'] = 2;
for (int i = 1; i <= a.size(); i++)
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
pre[i][j][k] = pre[i-1][j][k]+(mp[a[i-1]] == j and mp[b[i-1]] == k);
}
int get_distance(int a, int b){
int own = 0, share = 0;
for (int i = 0; i < 3; i++){ int j = (i+1)%3;
int cnt1 = pre[b+1][i][j]-pre[a][i][j];
int cnt2 = pre[b+1][j][i]-pre[a][j][i];
if (i == 0) share = cnt1-cnt2;
else if (cnt1-cnt2 != share) return -1;
own += min(cnt1, cnt2);
}return own+(abs(share)*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... |