# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
437167 | CaDe | Mutating DNA (IOI21_dna) | C++17 | 56 ms | 6020 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 <iostream>
#include <string>
#include <map>
#include <vector>
#include <map>
using namespace std;
const int maxN = 100005;
int pre[maxN][3][3];
map<int, int> mappea;
void init(std::string a, std::string b) {
mappea.insert(make_pair('C', 0));
mappea.insert(make_pair('A', 1));
mappea.insert(make_pair('T', 2));
for(int i = 0; i <3;++i)
for(int j = 0; j <3; ++j)
pre[0][i][j] = 0;
pre[0][mappea[a[0]]][mappea[b[0]]]++;
for(int k = 1; k < a.size(); ++k){
for(int i = 0; i <3;++i)
for(int j = 0; j <3; ++j)
pre[k][i][j] = pre[k-1][i][j];
pre[k][mappea[a[k]]][mappea[b[k]]]++;
}
}
int get_distance(int x, int y) {
int mat[3][3];
for(int i = 0; i <3;++i)
for(int j = 0; j <3; ++j){
mat[i][j] = pre[y][i][j];
if(x > 0) mat[i][j] -= pre[x-1][i][j];
}
for(int i = 0; i <3; ++i){
int num = 0, num2 = 0;
for(int j = 0; j < 3; ++j){
num += mat[i][j];
num2 += mat[j][i];
}
if(num != num2) return -1;
}
int resp = 0;
for(int i = 0; i < 3; ++i){
for(int j = i+1; j < 3; ++j){
int cicloDos = min(mat[i][j], mat[j][i]);
mat[i][j] -= cicloDos;
mat[j][i] -= cicloDos;
resp += cicloDos;
}
}
int ciclotres =0;
for(int i = 0; i <3;++i)
for(int j = 0; j <3; ++j)
if(i != j)
ciclotres += mat[i][j];
resp += 2*ciclotres/3;
return resp;
}
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... |