이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
using namespace std;
vector<vector<vector<int> > > cnt;
void init(std::string a, std::string b) {
int n = a.size();
cnt.resize(n, vector<vector<int> > (3, vector<int>(3, 0)));
for (int i = 0; i < n; i++) {
if (a[i] == 'T') a[i] = 'B';
if (b[i] == 'T') b[i] = 'B';
if (i) cnt[i] = cnt[i-1];
cnt[i][a[i]-'A'][b[i]-'A']++;
}
}
int get_distance(int x, int y) {
vector<vector<int> > tmp(3, vector<int>(3));
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) {
tmp[i][j] = cnt[y][i][j] - (x > 0 ? cnt[x-1][i][j] : 0);
}
int ans = 0;
vector<int> rem(3, 0);
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) {
if (i == j) continue;
if (tmp[i][j] < tmp[j][i]) {
ans += tmp[i][j];
tmp[j][i] -= tmp[i][j];
tmp[i][j] = 0;
} else {
ans += tmp[j][i];
tmp[i][j] -= tmp[j][i];
tmp[j][i] = 0;
}
rem[i] += tmp[i][j];
}
ans += rem[0] + rem[1];
if (rem[0] != rem[1] || rem[1] != rem[2])
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... |