| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 633216 | resting | Mutating DNA (IOI21_dna) | C++17 | 47 ms | 7416 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;
const int mx = 1e5+5;
int ps[mx][3][3] {};
void init(std::string a, std::string b) {
map<char, int> m = {{'A', 0}, {'C', 1}, {'T', 2}};
for(int i = 0; i < size(a); i++){
ps[i][m[a[i]]][m[b[i]]]++;
}
for(int i = 1; i < size(a); i++){
for(int a = 0; a < 3; a++){
for(int b = 0; b < 3; b++){
ps[i][a][b] += ps[i-1][a][b];
}
}
}
}
int get_distance(int x, int y) {
int z[3][3];
for(int a = 0; a < 3; a++)
for(int b = 0; b < 3; b++)
z[a][b] = ps[y][a][b];
if(x){
for(int a = 0; a < 3; a++)
for(int b = 0; b < 3; b++)
z[a][b] -= ps[x-1][a][b];
}
int res = 0;
for(int a = 0; a < 2; a++){
for(int b = a+1; b < 3; b++){
int t = min(z[a][b], z[b][a]);
res += t;
z[a][b] -= t;
z[b][a] -= t;
}
}
if(!z[0][1]){
swap(z[0][1], z[1][0]);
swap(z[1][2], z[2][1]);
swap(z[0][2], z[2][0]);
}
if(z[0][1] == z[1][2] && z[1][2] == z[2][0] && !z[1][0] && !z[2][1] && !z[0][2]){
return res + z[0][1] * 2;
}
else{
return -1;
}
return 0;
}
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... | ||||
