Submission #1057371

#TimeUsernameProblemLanguageResultExecution timeMemory
1057371TrentDNA 돌연변이 (IOI21_dna)C++17
22 / 100
1546 ms3932 KiB
#include "dna.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
typedef vector<int> vi;

string a, b;

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

int id(char v) {
	return v == 'A' ? 0 : v == 'C' ? 1 : 2;
}
int get_distance(int x, int y) {
	int cnt[3][3];
	forR(i, 3) forR(j, 3) cnt[i][j] = 0;
	REP(i, x, y+1) {
		cnt[id(a[i])][id(b[i])]++;
	}
	int ab=min(cnt[0][1], cnt[1][0]), ac=min(cnt[0][2], cnt[2][0]), bc=min(cnt[1][2], cnt[2][1]);
	cnt[0][1]-=ab, cnt[1][0]-=ab;
	cnt[0][2]-=ac, cnt[2][0]-=ac;
	cnt[1][2]-=bc, cnt[2][1]-=bc;
	int abt=max(cnt[0][1], cnt[1][0]), act=max(cnt[0][2], cnt[2][0]), bct=max(cnt[1][2], cnt[2][1]);
	if(abt == act && act == bct) {
		return ab + ac + bc + 2 * abt;
	} else return -1;
}
#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...