# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
531468 | yutabi | Mutating DNA (IOI21_dna) | C++17 | 45 ms | 6220 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"
int preTC[100007];
int preCT[100007];
int preTA[100007];
int preAT[100007];
int preAC[100007];
int preCA[100007];
void init(std::string a, std::string b)
{
for(int i=0;i<a.size();i++)
{
preTC[i+1]=preTC[i];
preCT[i+1]=preCT[i];
preTA[i+1]=preTA[i];
preAT[i+1]=preAT[i];
preAC[i+1]=preAC[i];
preCA[i+1]=preCA[i];
if(a[i]=='T' && b[i]=='C')
{
preTC[i+1]++;
}
if(a[i]=='T' && b[i]=='A')
{
preTA[i+1]++;
}
if(a[i]=='A' && b[i]=='C')
{
preAC[i+1]++;
}
if(a[i]=='C' && b[i]=='T')
{
preCT[i+1]++;
}
if(a[i]=='A' && b[i]=='T')
{
preAT[i+1]++;
}
if(a[i]=='C' && b[i]=='A')
{
preCA[i+1]++;
}
}
}
int get_distance(int x, int y)
{
int ans=0;
int TC=preTC[y+1]-preTC[x];
int CT=preCT[y+1]-preCT[x];
int TA=preTA[y+1]-preTA[x];
int AT=preAT[y+1]-preAT[x];
int AC=preAC[y+1]-preAC[x];
int CA=preCA[y+1]-preCA[x];
int mini;
mini=std::min(TC,CT);
ans+=mini;
TC-=mini;
CT-=mini;
mini=std::min(TA,AT);
ans+=mini;
TA-=mini;
AT-=mini;
mini=std::min(AC,CA);
ans+=mini;
AC-=mini;
CA-=mini;
mini=std::min(std::min(AT,TC),CA);
ans+=2*mini;
AT-=mini;
TC-=mini;
CA-=mini;
mini=std::min(std::min(TA,CT),AC);
ans+=2*mini;
TA-=mini;
CT-=mini;
AC-=mini;
if(AC || CA || AT || TA || TC || CT)
{
ans=-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... |