This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define N 100001
int AC[N];
int AT[N];
int CA[N];
int CT[N];
int TA[N];
int TC[N];
void init(string a,string b){
for(int i=0;i<a.size();i++){
AC[i]=AC[i-1]+(a[i]=='A' && b[i]=='C');
AT[i]=AT[i-1]+(a[i]=='A' && b[i]=='T');
CA[i]=CA[i-1]+(a[i]=='C' && b[i]=='A');
CT[i]=CT[i-1]+(a[i]=='C' && b[i]=='T');
TA[i]=TA[i-1]+(a[i]=='T' && b[i]=='A');
TC[i]=TC[i-1]+(a[i]=='T' && b[i]=='C');
}
}
int get_distance(int l,int r){
int o,p,q,s;
int ac,at,ca,ct,ta,tc;
l--;
ac=AC[r];
at=AT[r];
ca=CA[r];
ct=CT[r];
ta=TA[r];
tc=TC[r];
if(l>=0){
ac-=AC[l];
at-=AT[l];
ca-=CA[l];
ct-=CT[l];
ta-=TA[l];
tc-=TC[l];
}
p=min(ac,ca);
q=min(at,ta);
s=min(ct,tc);
o=p+q+s;
p=max(ac,ca)-p;
q=max(at,ta)-q;
s=max(ct,tc)-s;
if(p!=q || q!=s) o=-1;
else o+=p+q;
return o;
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | 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... |