제출 #1122943

#제출 시각아이디문제언어결과실행 시간메모리
1122943blackslexDNA 돌연변이 (IOI21_dna)C++20
35 / 100
32 ms3912 KiB
#include "dna.h"
#include<bits/stdc++.h>

using namespace std;

int n;
string s, t;
vector<int> prefs, preft, cnt;

int get (int l, int r, vector<int> &pref) {
	return pref[r] - (l ? pref[l - 1] : 0);
}

void init(std::string a, std::string b) {
	s = a; t = b;
	n = a.size();
	prefs.resize(n);
	preft.resize(n);
	cnt.resize(n);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'A') prefs[i]++;
		if (t[i] == 'A') preft[i]++;
		if (s[i] == 'A' && t[i] == 'T') cnt[i]++;
	}
	for (int i = 1; i < n; i++) {
		prefs[i] += prefs[i - 1];
		preft[i] += preft[i - 1];
		cnt[i] += cnt[i - 1];
	}
}

int get_distance(int x, int y) {
	if (get(x, y, prefs) != get(x, y, preft)) return -1;
	return cnt[y] - (x ? cnt[x - 1] : 0);
}
#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...