Submission #978241

# Submission time Handle Problem Language Result Execution time Memory
978241 2024-05-09T04:35:00 Z Amaarsaa Mutating DNA (IOI21_dna) C++17
0 / 100
24 ms 5916 KB
//#include "dna.h"
#include<bits/stdc++.h>

using namespace std;
int a[100004][3][3];
void init(string A, string B) {
	int n = A.size();
	for (int i = 0; i < n; i ++) {
		if ( A[i] == 'T') A[i] = 'B';
		if ( B[i] == 'T') B[i] = 'B';
		A[i] += 32;
		B[i] += 32;
		for (int j = 0; j <= 2; j ++) {
			for (int r = 0; r <= 2; r ++) {
				if ( i == 0) a[i][j][r] = 0;
				else a[i][j][r] = a[i - 1][j][r];		
			}
		}
		int x = A[i] - 'a';
		int y = B[i] - 'a';
		a[i][x][y] ++;
	}
}
int cnt(int l, int r, int x, int y){
	int s= a[r][x][y];
	if ( l == 0) return s;
	s -= (a[l - 1][x][y]);
	return s;
}
int get_distance(int x, int y) {
	int ans = 0;
	int ab = cnt(x, y, 0, 1), ba = cnt(x, y, 1, 0), ac = cnt(x, y, 0, 2), ca = cnt(x, y, 2, 0), bc = cnt(x, y, 1, 2), cb = cnt(x, y, 2, 1);
	x = min(ab, ba);
	ans += x;
	ab -= x;
	ba -= x;
	x = min(ac, ca);
	ans += x;
	ac -= x;
	ca -= x;
	x = min(bc, cb);
	ans += x;
	bc -= x;
	cb -= x;
	if ( (ab == 0 || bc == 0 || ca == 0) && (ba == 0 || ac == 0 || cb == 0)) return 0;
	ab += ba;
	bc += cb;
	ac += ca;
	int s = ab + bc + ac;
	return ans + ab + bc + ac - max(ab, max(bc, ac));
}

Compilation message

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:49:6: warning: unused variable 's' [-Wunused-variable]
   49 |  int s = ab + bc + ac;
      |      ^
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 5916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 5916 KB Output isn't correct
2 Halted 0 ms 0 KB -