# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
682842 | paulo_ar | Mutating DNA (IOI21_dna) | C++17 | 35 ms | 7368 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;
int a [100002];
int t [100002];
int ap [100002];
int tp [100002];
int a0t [100002];
int a0c [100002];
int c0a [100002];
int c0t [100002];
int t0a [100002];
int t0c [100002];
void init(std::string s1, std::string s2) {
for(int i=0; i<s1.size(); i++){
if(s1[i]=='a')a[i]=1;
else if(s1[i]=='t')t[i]=1;
if(s2[i]=='a')ap[i]=1;
else if(s2[i]=='t')tp[i]=1;
if(s1[i]=='a' && s2[i]=='t'){
a0t[i]=1;
}if(s1[i]=='a' && s2[i]=='c'){
a0c[i]=1;
}if(s1[i]=='c' && s2[i]=='t'){
c0t[i]=1;
}if(s1[i]=='c' && s2[i]=='a'){
c0a[i]=1;
}if(s1[i]=='t' && s2[i]=='a'){
t0a[i]=1;
}if(s1[i]=='t' && s2[i]=='c'){
t0c[i]=1;
}
a[i]+=a[i-1];
t[i]+=t[i-1];
ap[i]+=ap[i-1];
tp[i]+=tp[i-1];
a0t[i]+=a0t[i-1];
a0c[i]+=a0c[i-1];
t0a[i]+=t0a[i-1];
t0c[i]+=t0c[i-1];
c0a[i]+=c0a[i-1];
c0t[i]+=c0t[i-1];
}
}
int get_distance(int x, int y) {
int ans=0;
int macro;
if(a[y]-a[x-1]!=ap[y]-ap[x-1] || t[y]-t[x-1]!=tp[y]-tp[x-1])return -1;
ans+=min(a0t[y]-a0t[x-1],t0a[y]-t0a[x-1]);
macro=ans;
ans+= (2*(a0t[y]-a0t[x-1]-macro));
ans+=min(c0t[y]-c0t[x-1],t0c[y]-t0c[x-1]);
ans+=min(a0c[y]-a0c[x-1],c0a[y]-c0a[x-1]);
return ans;
}
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... |