제출 #437056

#제출 시각아이디문제언어결과실행 시간메모리
437056awuawuawuDNA 돌연변이 (IOI21_dna)C++17
56 / 100
60 ms5248 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...