제출 #809192

#제출 시각아이디문제언어결과실행 시간메모리
809192OAleksaDNA 돌연변이 (IOI21_dna)C++17
56 / 100
32 ms6612 KiB
#include <bits/stdc++.h>
#include "dna.h"
 
#define f first
#define s second
using namespace std; 

const int maxn = 1e5 + 69;
vector<int> pa1(maxn), pc1(maxn), pt1(maxn);
vector<int> pa2(maxn), pc2(maxn), pt2(maxn);
vector<int> p(maxn);
void init(string a, string b) {
	int n = a.size();
	p[0] = (a[0] != b[0]);
	for(int i = 1;i < n;i++)
		p[i] = p[i - 1] + (a[i] != b[i]);
	pa1[0] = (a[0] == 'A');
	pc1[0] = (a[0] == 'C');
	pt1[0] = (a[0] == 'T');
	pa2[0] = (b[0] == 'A');
	pc2[0] = (b[0] == 'C');
	pt2[0] = (b[0] == 'T');
	for(int i = 1;i < n;i++) {
		pa1[i] = pa1[i - 1] + (a[i] == 'A');
		pc1[i] = pc1[i - 1] + (a[i] == 'C');
		pt1[i] = pt1[i - 1] + (a[i] == 'T');
		pa2[i] = pa2[i - 1] + (b[i] == 'A');
		pc2[i] = pc2[i - 1] + (b[i] == 'C');
		pt2[i] = pt2[i - 1] + (b[i] == 'T');
	}
}

int get_distance(int x, int y) {
	int x1 = pa1[y] - (x == 0 ? 0 : pa1[x - 1]);
	int x2 = pc1[y] - (x == 0 ? 0 : pc1[x - 1]);
	int x3 = pt1[y] - (x == 0 ? 0 : pt1[x - 1]);
	int x4 = pa2[y] - (x == 0 ? 0 : pa2[x - 1]);
	int x5 = pc2[y] - (x == 0 ? 0 : pc2[x - 1]);
	int x6 = pt2[y] - (x == 0 ? 0 : pt2[x - 1]);
	if(x1 != x4 || x2 != x5 || x3 != x6)
		return -1;
	else 
		return (p[y] - (x == 0 ?0 :  p[x - 1]) + 1)	/ 2;
}

 
// int main()
// {
	  // ios_base::sync_with_stdio(false);
	  // cin.tie(0);
	  // cout.tie(0);
	  // int tt = 1;
		// //cin >> tt;
	  // while(tt--) {
			// int n, q;
			// cin >> n >> q;
			// string a, b;
			// cin >> a >> b;
			// init(a, b);
			// for(int i = 0;i < q;i++) {
				// int l, r;
				// cin >> l >> r;
				// cout << get_distance(l, r) << endl;
			// }
		// }
    // return 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...