이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debug_out(){cerr<<endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cerr << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 1e5 + 10;
int n, cnt[maxn][6], part[maxn][9];
void init(std::string s, std::string t) {
n = s.size();
for (int i = 1; i <= n; i++){
int x = (s[i-1] == 'A'? 0: (s[i-1] == 'T'? 1: 2));
int y = (t[i-1] == 'A'? 0: (t[i-1] == 'T'? 1: 2));
cnt[i][x]++;
cnt[i][y+3]++;
part[i][x*3+y]++;
}
for (int j = 0; j < 9; j++){
for (int i = 1; i <= n; i++){
part[i][j] += part[i-1][j];
if (j < 6) cnt[i][j] += cnt[i-1][j];
}
}
}
int get_distance(int x, int y) {
y++, x++;
for (int i = 0; i < 3; i++){
if (cnt[y][i] - cnt[x-1][i] != cnt[y][i+3] - cnt[x-1][i+3]) return -1;
}
int tmp[9];
for (int i = 0; i < 9; i++){
tmp[i] = part[y][i] - part[x-1][i];
// debug(i, tmp[i]);
}
int res = 0;
for (int i = 0; i < 9; i++){
int x = i / 3, y = i % 3;
int idx = y * 3 + x;
int val = min(tmp[i], tmp[idx]);
//debug(i, idx, val);
res += val;
tmp[i] -= val;
if (idx != i) tmp[idx] -= val;
}
assert(tmp[1] == tmp[5] && tmp[5] == tmp[6] && tmp[2] == tmp[7] && tmp[7] == tmp[3]);
res += tmp[1] + tmp[2];
return y - x + 1 - 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... |