# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1021966 | HappyCapybara | Mutating DNA (IOI21_dna) | C++17 | 46 ms | 6448 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<bits/stdc++.h>
using namespace std;
vector<vector<int>> ps;
void init(string a, string b){
ps.resize(6, vector<int>(a.size()+1, 0));
for (int i=0; i<a.size(); i++){
for (int j=0; j<6; j++) ps[j][i+1] = ps[j][i];
if (a[i] == 'A' && b[i] == 'T') ps[0][i+1]++;
if (a[i] == 'A' && b[i] == 'C') ps[1][i+1]++;
if (a[i] == 'T' && b[i] == 'A') ps[2][i+1]++;
if (a[i] == 'T' && b[i] == 'C') ps[3][i+1]++;
if (a[i] == 'C' && b[i] == 'A') ps[4][i+1]++;
if (a[i] == 'C' && b[i] == 'T') ps[5][i+1]++;
}
}
int get_distance(int x, int y) {
vector<int> v(6);
for (int i=0; i<6; i++) v[i] = ps[i][y+1] - ps[i][x];
int p = min(v[0], v[2])+min(v[1], v[4])+min(v[3], v[5]);
if (v[0]+v[1] != v[2]+v[4] || v[2]+v[3] != v[0]+v[5] || v[4]+v[5] != v[1]+v[3]) return -1;
else return p + (v[0]+v[1]+v[2]+v[3]+v[4]+v[5]-2*p)/3 * 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... |