# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
483594 | ponytail | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 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 <string>
#include <bits/stdc++.h>
using namespace std;
int get_distance(int x, int y) {
int res[6];
for(int i=0; i<6; i++) res[i] = ps[i][y] - (x==0 ? 0 : ps[i][x-1]);
if(res[0] + res[4] != res[1] + res[5]) return -1;
if(res[1] + res[3] != res[0] + res[2]) return -1;
if(res[2] + res[5] != res[3] + res[4]) return -1;
int ans = min(res[0], res[1]) + min(res[2], res[3]) + min(res[4], res[5]);
res[0] -= min(res[0], res[1]);
res[1] -= min(res[0], res[1]);
res[2] -= min(res[2], res[3]);
res[3] -= min(res[2], res[3]);
res[4] -= min(res[4], res[5]);
res[5] -= min(res[4], res[5]);
for(int i=0; i<6; i++) ans += res[i];
ans--;
return ans;
}