# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1082316 | SiliconSquared | Mutating DNA (IOI21_dna) | C++17 | 23 ms | 5904 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"
using namespace std;
#include <vector>
vector<int> ca;
vector<int> ac;
vector<int> ct;
vector<int> tc;
vector<int> ta;
vector<int> at;
void init(std::string a, std::string b) {
ca.resize(a.size()+1,0);
ct.resize(a.size()+1,0);
ac.resize(a.size()+1,0);
at.resize(a.size()+1,0);
ta.resize(a.size()+1,0);
tc.resize(a.size()+1,0);
for (int i=0;i<a.size();i++){
ca[i+1]=ca[i];
ct[i+1]=ct[i];
at[i+1]=at[i];
ac[i+1]=ac[i];
ta[i+1]=ta[i];
tc[i+1]=tc[i];
if (a[i]=='C'){
if (b[i]=='A'){
ca[i+1]++;
}else{
ct[i+1]++;
}
}else if (a[i]=='T'){
if (b[i]=='A'){
ta[i+1]++;
}else{
tc[i+1]++;
}
}else{
if (b[i]=='C'){
ac[i+1]++;
}else{
at[i+1]++;
}
}
}
}
int get_distance(int x, int y) {
y++;
if (ca[y]-ca[x]+ct[y]-ct[x]!=ac[y]-ac[x]+tc[y]-tc[x]){
return -1;
}
if (ta[y]-ta[x]+tc[y]-tc[x]!=at[y]-at[x]+ct[y]-ct[x]){
return -1;
}
if (ac[y]-ac[x]+at[y]-at[x]!=ca[y]-ca[x]+ta[y]-ta[x]){
return -1;
}
int z=ca[y]-ca[x]+ct[y]-ct[x]+ta[y]-ta[x]+tc[y]-tc[x]+ac[y]-ac[x]+at[y]-at[x]-1;
z-=min(ca[y]-ca[x],ac[y]-ac[x])/2;
z-=min(ta[y]-ta[x],at[y]-at[x])/2;
z-=min(tc[y]-tc[x],ct[y]-ct[x])/2;
return z;
}
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... |