# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
437947 | Haidara | Mutating DNA (IOI21_dna) | C++17 | 58 ms | 4872 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;
const int maxn=100100;
int At[maxn],ta[maxn],tc[maxn],ct[maxn],ac[maxn],ca[maxn];
void init(string a, string b)
{
for(int i=0;i<a.size();i++)
{
At[i+1]=At[i];
ta[i+1]=ta[i];
tc[i+1]=tc[i];
ct[i+1]=ct[i];
ac[i+1]=ac[i];
ca[i+1]=ca[i];
if(a[i]=='A')
{
if(b[i]=='T')
At[i+1]++;
else if(b[i]=='C')
ac[i+1]++;
}
else if(a[i]=='T')
{
if(b[i]=='A')
ta[i+1]++;
else if(b[i]=='C')
tc[i+1]++;
}
else if(a[i]=='C')
{
if(b[i]=='A')
ca[i+1]++;
else if(b[i]=='T')
ct[i+1]++;
}
}
return ;
}
int get_distance(int x, int y)
{
y++;
if((ta[y]-ta[x]+tc[y]-tc[x]!=At[y]-At[x]+ct[y]-ct[x])||(At[y]-At[x]+ac[y]-ac[x]!=ta[y]-ta[x]+ca[y]-ca[x])||(ca[y]-ca[x]+ct[y]-ct[x]!=tc[y]-tc[x]+ac[y]-ac[x]))
return -1;
return min(At[y]-At[x],ta[y]-ta[x])+min(tc[y]-tc[x],ct[y]-ct[x])+min(ac[y]-ac[x],ca[y]-ca[x]) +(abs(At[y]-At[x]-ta[y]+ta[x])+abs(tc[y]-tc[x]-ct[y]+ct[x])+abs(ac[y]-ac[x]-ca[y]+ca[x]))*2/3;
}
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... |