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;
#define dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=1e6+99;
int n,ps[N][3][3],cnt[3][3];
int G(char c){
if(c=='A') return 0;
if(c=='T') return 1;
return 2;
}
void init(string a,string b){
n=a.size();
f(i,1,n+1){
f(j,0,3) f(k,0,3) ps[i][j][k]=ps[i-1][j][k];
ps[i][G(a[i-1])][G(b[i-1])]++;
}
}
int get_distance(int l, int r) {
int ans=0;
r++;
f(i,0,3) f(j,0,3) cnt[i][j]=ps[r][i][j]-ps[l][i][j];
f(i,0,3){
f(j,i+1,3){
while(cnt[i][j] && cnt[j][i]){
ans++;
cnt[i][j]--;
cnt[j][i]--;
}
}
}
while(cnt[0][1] && cnt[1][2] && cnt[2][0]){
ans+=2;
cnt[0][1]--;
cnt[1][2]--;
cnt[2][0]--;
}
while(cnt[0][2] && cnt[2][1] && cnt[1][0]){
ans+=2;
cnt[0][2]--;
cnt[2][1]--;
cnt[1][0]--;
}
f(i,0,3) f(j,0,3){
if(i!=j && cnt[i][j]){
return -1;
}
}
return ans;
}
# | 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... |