제출 #438889

#제출 시각아이디문제언어결과실행 시간메모리
438889jhtanDNA 돌연변이 (IOI21_dna)C++17
21 / 100
41 ms3752 KiB
#include "dna.h"
#include <iostream>

using namespace std;

string A, B;

void init(std::string a, std::string b) {
	A = a;
	B = b;
}

int get_distance(int x, int y) {
	int C1[3] = {0, 0, 0};
	int C2[3] = {0, 0, 0};
	for(int i=x; i<=y; i++) {
		if(A[i] == 'A') C1[0]++;
		if(A[i] == 'T') C1[1]++;
		if(A[i] == 'C') C1[2]++;
		if(B[i] == 'A') C2[0]++;
		if(B[i] == 'T') C2[1]++;
		if(B[i] == 'C') C2[2]++;
	}
	if(C1[0] != C2[0] || C1[1] != C2[1] || C1[2] != C2[2]) return -1;

	if(y-x <= 2) { 	
		if(y-x == 0) return 0;

		if(y-x == 1) {
			if(A[x] == B[x]) return 0;
			return 1;
		}

		if(A[x] == B[x] && A[x+1] == B[x+1] && A[y] == B[y]) return 0;
		if(A[x] == B[x] || A[x+1] == B[x+1] || A[y] == B[y]) return 1;
		return 2;
	}

	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...