Submission #1236935

#TimeUsernameProblemLanguageResultExecution timeMemory
1236935i_love_mritiMutating DNA (IOI21_dna)C++20
0 / 100
18 ms2624 KiB
#include <bits/stdc++.h>
#include "dna.h"
using namespace std;

const int mxN = 2e5 + 1000;

string A, B;

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

int get_distance(int x, int y){
	int a = 0, c = 0, t = 0, good = 0, at = 0, ta = 0, ac = 0, ca = 0, tc = 0, ct = 0;
	for(int i = x; i <= y; ++i){
		a += A[i] == 'A';
		a -= B[i] == 'A';
		c += A[i] == 'C';
		c -= B[i] == 'C';
		t += A[i] == 'T';
		t -= B[i] == 'T';
		if(A[i] == 'A' && B[i] == 'T') ++at;
		else if(A[i] == 'T' && B[i] == 'A') ++ta;
		else if(A[i] == 'A' && B[i] == 'C') ++ac;
		else if(A[i] == 'C' && B[i] == 'A') ++ca;
		else if(A[i] == 'C' && B[i] == 'T') ++ct;
		else if(A[i] == 'T' && B[i] == 'C') ++tc;
		else ++good;
	}
	if(a == 0 && c == 0 && t == 0){
		return abs(at - ta) + abs(ac - ca) + abs(tc - ct) + ((y - x + 1) - abs(at - ta) - abs(ac - ca) - abs(tc - ct) - good - 1);
	}else{
		return -1;
	}
}

/*int main(){
	#ifndef ONLINE_JUDGE
	freopen("inp.in", "r", stdin);
	freopen("output.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0);
	cin.tie(nullptr); cout.tie(nullptr);


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