This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// main.cpp
//
// Created by Panagiotis Chadjicostas on
// Copyright © Panagiotis Hadjicostas. All rights reserved.
//
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
typedef int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define fo(i,a,b) for(int i = a; i<=b; i++)
#define f(i,b) for(int i=0;i<b;i++)
#define F first
#define S second
#define sz size
#define ls s,m,idx<<1
#define rs m+1,e,idx<<1|1
const ll MOD=ll(1e9)+7;
const ll MAXN=2*ll(1e6);
void checker(){
ll n=rand()%20+2;
vi a(n,ll());
for(ll i=0;i<n;i++){
a[i]=rand()%20+2;
}
for(ll b=0;b<(1<<n);b++){
vi on,off;
for(ll i=0;i<n;i++){
if(i&(1<<i)){
on.push_back(i);
}
else{
off.push_back(i);
}
}
}
}
///////////////////////////////////////////////////////////////////////
int pre[200005][3][3], mp[ll('Z')+1];
void init(string a, string b){
mp['A'] = 0, mp['C'] = 1, mp['T'] = 2;
for (ll i = 1; i <= a.size(); i++)
for (ll j = 0; j < 3; j++)
for (ll k = 0; k < 3; k++)
pre[i][j][k] = pre[i-1][j][k]+(mp[a[i-1]] == j and mp[b[i-1]] == k);
}
int get_distance(int x, int y){
x++,y++;
ll temp=0;
ll ans=0;
for(ll i=0;i<3;i++){
ll j=(i+1)%3;
ll c1=pre[y][i][j]-pre[x-1][i][j];
ll c2=pre[y][j][i]-pre[x-1][j][i];
if(!i)
temp=c1-c2;
if(temp!=c1-c2)
return -1;
ans+=min(c1,c2);
}
ans+=2*abs(temp);
return ans;
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:64:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for (ll i = 1; i <= a.size(); i++)
| ~~^~~~~~~~~~~
dna.cpp:67:57: warning: array subscript has type 'char' [-Wchar-subscripts]
67 | pre[i][j][k] = pre[i-1][j][k]+(mp[a[i-1]] == j and mp[b[i-1]] == k);
| ^
dna.cpp:67:77: warning: array subscript has type 'char' [-Wchar-subscripts]
67 | pre[i][j][k] = pre[i-1][j][k]+(mp[a[i-1]] == j and mp[b[i-1]] == k);
| ^
# | 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... |