# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
777345 | Trisanu_Das | Mutating DNA (IOI21_dna) | C++17 | 41 ms | 7400 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 pref[100005][3][3];
map<char, int> mp;
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++) pref[i][j][k] = pref[i - 1][j][k] + (mp[a[i - 1]] == j && mp[b[i - 1]] == k);
}
int get_distance(int x, int y){
int actual = 0, add = 0;
for(int i = 0; i < 3; i++){
int j = (i + 1) % 3;
int m = pref[y + 1][i][j] - pref[x][i][j], n = pref[y + 1][j][i] - pref[x][j][i];
if(i == 0) add = m - n;
else if(m - n != add) return -1;
actual += min(m, n);
}
return actual + abs(add) * 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... |