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 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];
printf("%d %d %d %d %d %d\n",TC,CT,TA,AT,AC,CA);
int mini;
mini=min(TC,CT);
ans+=mini;
TC-=mini;
CT-=mini;
mini=min(TA,AT);
ans+=mini;
TA-=mini;
AT-=mini;
mini=min(AC,CA);
ans+=mini;
AC-=mini;
CA-=mini;
mini=min(min(AT,TC),CA);
ans+=2*mini;
AT-=mini;
TC-=mini;
CA-=mini;
mini=min(min(AT,CT),AC);
ans+=2*mini;
TA-=mini;
CT-=mini;
AC-=mini;
if(AC || CA || AT || TA || TC || CT)
{
return -1;
}
return ans;
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:16:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i=0;i<a.size();i++)
| ~^~~~~~~~~
# | 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... |