이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define MASK(i) (1LL<<(i))
#define BIT(mask,i) (((mask) >> (i))&1)
ll cnt[100100][3][3];
ll cv(char x){
if (x=='A')return 0;
if (x=='C')return 1;
return 2;
}
void init(std::string a, std::string b) {
ll n = sz(a);
for (ll i = 0;i < n;i ++){
if (i)for (ll j = 0;j < 3;j ++)for (ll k = 0;k < 3;k ++)cnt[i][j][k] = cnt[i-1][j][k];
cnt[i][cv(a[i])][cv(b[i])]++;
}
}
int get_distance(int x, int y) {
ll tmp[3][3];
for (ll i = 0;i < 3;i ++)for (ll j = 0;j < 3;j ++){
tmp[i][j] = cnt[y][i][j];
if (x)tmp[i][j] -= cnt[x-1][i][j];
}
for (ll i = 0;i < 3;i ++){
if (tmp[i][0] + tmp[i][1] + tmp[i][2] != tmp[0][i] + tmp[1][i] + tmp[2][i])return -1;
}
ll res = 0;
res += min(tmp[0][2],tmp[2][0]);
res += min(tmp[0][1],tmp[1][0]);
res += min(tmp[1][2],tmp[2][1]);
// cout<<(max(tmp[0][2],tmp[2][0]) - min(tmp[0][2],tmp[2][0]))<<endl;
res += (max(tmp[0][2],tmp[2][0]) - min(tmp[0][2],tmp[2][0])) * 2;
return res;
}
# | 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... |