이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); ++i)
#define rrep(i, n) for(ll i = ll(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define SZ(a) int(a.size())
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
const int inf = 1001001001;
const ll linf = 1001001001001001001;
template<class T>
bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int n;
int sum[3][3][100010];
map<char, int> mp = {{'A', 0},
{'T', 1},
{'C', 2}};
void init(string a, string b) {
n = SZ(a);
rep(i, n) {
rep(j, 3) rep(k, 3) sum[j][k][i + 1] = sum[j][k][i];
++sum[mp[a[i]]][mp[b[i]]][i + 1];
}
}
int get_distance(int x, int y) {
++y;
vvi v(3, vi(3));
vi in(3), out(3);
rep(i, 3) rep(j, 3) {
v[i][j] = sum[i][j][y] - sum[i][j][x];
out[i] += v[i][j];
in[j] += v[i][j];
}
rep(i, 3) if (in[i] != out[i]) return -1;
int ans = 0;
rep(i, 3) rep2(j, i + 1, 3) {
int now = min(v[i][j], v[j][i]);
ans += now;
v[i][j] -= now;
v[j][i] -= now;
}
ans += v[0][1] * 2;
ans += v[1][0] * 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... |