이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
int pref[1000000][3][3];
map<char,int> m;
void init(std::string a, std::string b) {
m['A']=0;
m['C']=1;
m['T']=2;
rep(j,0,3){
rep(k,0,3){
pref[0][j][k]=0;
}
}
rep(i,0,(int)a.size()){
rep(j,0,3){
rep(k,0,3){
pref[i+1][j][k]=pref[i][j][k];
}
}
pref[i+1][m[a[i]]][m[b[i]]]++;
}
}
int arr[3][3];
int get_distance(int x, int y) {
y++;
rep(i,0,3){
rep(j,0,3){
arr[i][j]=pref[y][i][j]-pref[x][i][j];
}
}
int bal[3];
rep(i,0,3)bal[i]=0;
rep(i,0,3){
rep(j,0,3){
bal[i]+=arr[i][j];
bal[j]-=arr[i][j];
}
}
rep(i,0,3){
if(bal[i]!=0)return -1;
}
int ans=0;
rep(i,0,3){
rep(j,0,3){
if(i==j)arr[i][j]=0;
int k=min(arr[i][j],arr[j][i]);
ans+=k;
arr[i][j]-=k;
arr[j][i]-=k;
//cerr<<arr[i][j]<<" ";
}//cerr<<endl;
}
int tot=0;
rep(i,0,3){
rep(j,0,3){
tot+=arr[i][j];
}
}
tot/=3;
tot*=2;
ans+=tot;
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... |