# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
677101 | hello_there_123 | Mutating DNA (IOI21_dna) | C++17 | 37 ms | 7440 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;
string s, t;
int n;
int lol[4][4][200005];
int mat[4][4];
//lol[i][j] -> i wants to turn into j
void init(std::string a, std::string b) {
int n = a.length();
for(int i=0;i<n;i++){
int fir, sec;
if(a[i] == 'A') fir = 0;
if(a[i] == 'T') fir = 1;
if(a[i] == 'C') fir = 2;
if(b[i] == 'A') sec = 0;
if(b[i] == 'T') sec = 1;
if(b[i] == 'C') sec = 2;
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
if(i!=0) lol[j][k][i] = lol[j][k][i-1];
}
}
if(a[i]==b[i]) continue;
lol[fir][sec][i]++;
}
}
int get_distance(int z, int y) {
int ans = 0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(z>0) mat[i][j] = lol[i][j][y] - lol[i][j][z-1];
else mat[i][j] = lol[i][j][y];
}
}
int x = min(mat[0][1],mat[1][0]);
ans+=x;
mat[0][1]-=x;
mat[1][0]-=x;
x = min(mat[0][2],mat[2][0]);
ans+=x;
mat[0][2]-=x;
mat[2][0]-=x;
x = min(mat[1][2],mat[2][1]);
ans+=x;
mat[1][2]-=x;
mat[2][1]-=x;
if(mat[0][1] + mat[0][2] == mat[1][0] + mat[2][0] && mat[1][0]+mat[1][2] == mat[0][1] + mat[2][1] && mat[2][0]+mat[2][1] == mat[0][2]+mat[1][2]){
ans+=2*(mat[0][1] + mat[0][2]);
return ans;
}
else return -1;
}
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... |