이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
vector<array<array<int,3>,3>> pre;
int f(char x){
if(x=='A') return 0;
if(x=='T') return 1;
return 2;
}
void init(string a,string b){
array<array<int,3>,3> cur;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cur[i][j]=0;
int n = sz(a);
pre.resize(n);
for(int i=0;i<n;i++){
array<int,2> val={f(a[i]),f(b[i])};
cur[val[0]][val[1]]++;
pre[i]=cur;
}
}
int get_distance(int x,int y){
array<array<int,3>,3> res=pre[y];
if(x>0){
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
res[i][j]-=pre[x-1][i][j];
}
int cur=min({res[0][2],res[2][1],res[1][0]});
int ans=cur*2;
res[0][2]-=cur;
res[2][1]-=cur;
res[1][0]-=cur;
cur=min({res[0][1],res[1][2],res[2][0]});
ans+=cur*2;
res[0][1]-=cur;
res[1][2]-=cur;
res[2][0]-=cur;
if(res[0][1]!=res[1][0]) return -1;
else ans+=res[0][1];
if(res[0][2]!=res[2][0]) return -1;
else ans+=res[0][2];
if(res[1][2]!=res[2][1]) return -1;
else ans+=res[1][2];
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... |