이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using tint = long long;
using ld = long double;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
using pi = pair<int,int>;
using pl = pair<tint,tint>;
using vi = vector<int>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vl = vector<tint>;
using vb = vector<bool>;
#define pb push_back
#define pf push_front
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
#define ins insert
#define f first
#define s second
#define mp make_pair
#define DBG(x) cerr << #x << " = " << x << endl;
const int MOD = 1e9+7;
const int mod = 998244353;
const int MX = 1e5+5;
const tint INF = 1e18;
const int inf = 2e8;
const ld PI = acos(ld(-1));
const ld eps = 1e-5;
#include "dna.h"
int AA[MX], AC[MX], AT[MX], BA[MX], BC[MX], BT[MX];
int eq[MX];
void init(std::string a, std::string b) {
FOR(i, 1, sz(a)+1){
eq[i] = eq[i-1]+(a[i-1] == b[i-1]);
AA[i] = AA[i-1]+(a[i-1] == 'A');
AC[i] = AC[i-1]+(a[i-1] == 'C');
AT[i] = AT[i-1]+(a[i-1] == 'T');
}
FOR(i, 1, sz(b)+1){
BA[i] = BA[i-1]+(b[i-1] == 'A');
BC[i] = BC[i-1]+(b[i-1] == 'C');
BT[i] = BT[i-1]+(b[i-1] == 'T');
}
}
int get_distance(int x, int y) {
++x; ++y;
if(AA[y]-AA[x-1] != BA[y]-BA[x-1] || AC[y]-AC[x-1] != BC[y]-BC[x-1] || AT[y]-AT[x-1] != BT[y]-BT[x-1]) return -1;
//cout << "DEBUG:" << endl;
//cout << AA[y] << " " << AA[x-1] << " " << BA[y] << " " << BA[x-1] << endl;
return ((y-x+1)-(eq[y]-eq[x-1]))/2+(((y-x+1)-(eq[y]-eq[x-1])) % 2);
}
# | 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... |