Submission #1142160

#TimeUsernameProblemLanguageResultExecution timeMemory
1142160mehdibaDNA 돌연변이 (IOI21_dna)C++20
0 / 100
20 ms5188 KiB
#include "dna.h"
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
string a, b;
vector<int> p(1e5), faa(1e5), fta(1e5), fca(1e5), fab(1e5), ftb(1e5), fcb(1e5);

void init(string A, string B){
	a = A, b = 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]);
		faa[i] = faa[i - 1] + (a[i] == 'A');
		fta[i] = fta[i - 1] + (a[i] == 'T');
		fca[i] = fca[i - 1] + (a[i] == 'C');
		fab[i] = fab[i - 1] + (b[i] == 'A');
		ftb[i] = ftb[i - 1] + (b[i] == 'T');
		fcb[i] = fcb[i - 1] + (b[i] == 'C');
	}
}

int get_distance(int x, int y){
	int cnt = p[y] - (x ? p[x - 1] : 0);
	int ffaa = faa[y] - (x ? faa[x - 1] : 0);
	int ffat = fta[y] - (x ? fta[x - 1] : 0);
	int ffac = fca[y] - (x ? fca[x - 1] : 0);
	int ffba = fab[y] - (x ? fab[x - 1] : 0);
	int ffbt = ftb[y] - (x ? ftb[x - 1] : 0);
	int ffbc = fcb[y] - (x ? fcb[x - 1] : 0);

	if(cnt % 2 || ffaa != ffba || ffat != ffbt || ffac != ffbc) return -1;
	return cnt / 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...