This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* * * * * * * * * *
* ID: Haidara *
* LANG: C++17 *
* PROB: *
* * * * * * * * * */
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,x,n) for(int i=x;i<n;i++)
#define FOR(i,n) rep(i,0,n)
#define per(i,x,n) for(int i=x;i>n;i--)
#define ROF(i,x) for(int i=x;i>=0;i--)
#define v(i) vector< i >
#define p(i,j) pair< i , j >
#define pii pair<int,int>
#define m(i,j) map< i , j >
#define pq(i) priority_queue< i >
#define ff first
#define all(x) x.begin(),x.end()
#define ss second
#define pp push_back
using namespace std;
const int mod=1e9+7;
const int maxn=100100;
int At[maxn],ta[maxn],tc[maxn],ct[maxn],ac[maxn],ca[maxn];
void init(string a, string b)
{
FOR(i,a.size())
{
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])
return -1;
if(At[y]-At[x]+ac[y]-ac[x]!=ta[y]-ta[x]+ca[y]-ca[x])
return -1;
if(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)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:8:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define rep(i,x,n) for(int i=x;i<n;i++)
| ^
dna.cpp:9:18: note: in expansion of macro 'rep'
9 | #define FOR(i,n) rep(i,0,n)
| ^~~
dna.cpp:27:5: note: in expansion of macro 'FOR'
27 | FOR(i,a.size())
| ^~~| # | 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... |