# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
979825 | batsukh2006 | Mutating DNA (IOI21_dna) | C++17 | 29 ms | 8208 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 mxN=1e5+1;
int mp[mxN][3][3];
int f[mxN][3],s[mxN][3];
void init(string a, string b){
map<char,int> m;
m['A']=0;
m['T']=1;
m['C']=2;
for(int i=1; i<=a.size(); i++){
for(int j=0; j<3; j++){
f[i][j]=f[i-1][j];
s[i][j]=s[i-1][j];
for(int k=0; k<3; k++){
mp[i][j][k]=mp[i-1][j][k];
}
}
f[i][m[a[i-1]]]++;
s[i][m[b[i-1]]]++;
mp[i][m[a[i-1]]][m[b[i-1]]]++;
}
}
int get_distance(int x, int y){
for(int i=0; i<3; i++){
if(f[y+1][i]-f[x][i]!=s[y+1][i]-s[x][i]){
return -1;
}
}
int ans=y-x+1;
for(int i=0; i<3; i++){
for(int j=i; j<3; j++){
ans-=min(mp[y+1][i][j]-mp[x][i][j],mp[y+1][j][i]-mp[x][j][i]);
}
}
return max(ans-1,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... |