Dao cot

mail@pastecode.io avatar
unknown
plain_text
a year ago
21 kB
4
Indexable
Never
Trong ma trận nhị phân, phép đảo cột của ma trận là việc thay thế các giá trị của cột
đó từ 0 -> 1 và từ 1 -> 0. Cho ma trận nhị phân NxM (N <= 100, M <= 20), hỏi sau K
lần đảo cột thì số hàng gồm toàn số 1 nhiều nhất có thể thu được là bao nhiêu. (Yêu
cầu phải đảo cột đúng K lần và một cột có thể được đảo nhiều lần)
Ví dụ
Với ví dụ bên, nếu K = 1, ta sẽ có kết quả lớn nhất khi đảo cột thứ 2 và thu được 1
hàng gồm toàn số 1 là hàng thứ 4. Nếu K = 2, kết quả thu được là 2 khi đảo cột thứ 2
và cột thứ 3.

0 1 0 0 0
1 0 0 1 1
0 0 0 0 0
1 0 1 1 1
1 0 0 1 1

K=1, có 1 hàng toàn 1
00000
11011
01000
11111
11011

K=2, có 2 hàng toàn 1
00100
11111
01100
11011
11111


Input: Cho 3 số N, M, K
Tiếp theo là ma trận NxM
Output: In ra số lượng hàng toàn 1 nhiều nhất định dạng như bên dưới
Case #1 1
Case #2 2

10
5 5 1
0 1 0 0 0
1 0 0 0 0
0 0 0 0 0 
1 0 1 1 1
1 0 0 1 1
5 5 2
0 1 0 0 0
1 0 0 1 1
0 0 0 0 0 
1 0 1 1 1
1 0 0 1 1
50 10 21
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1 0 1 1 1 0 0 
0 0 1 1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 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

#include <stdio.h>
#define MAX_N 100
#define MAX_M 20

int rowValue[MAX_N];
int zeroCnt[MAX_N]; //Number of "0" cell of this row
int duplicateCnt[MAX_N]; //Number of rows that are the same
int valNum = 0;

int main() {
	int T;
	int N, M, K;
	scanf("%d", &T);
	int tmpDigit, tmpVal, tmpCnt0;
	int j;
	for (int tc = 1; tc <= T; tc++) {
		scanf("%d%d%d", &N, &M, &K);
		valNum = 0;
		for (int i = 0; i < N; i++) {
			tmpVal = tmpCnt0 = 0;
			for (j = 0; j < M; j++) {
				scanf("%d", &tmpDigit);
				tmpVal = (tmpVal << 1) | tmpDigit;
				if (tmpDigit == 0) tmpCnt0++;
			}
			for (j = 0; j < valNum; j++) {
				if (tmpVal == rowValue[j]) { //There are rows that are same with this row, increase duplicate count
					duplicateCnt[j]++;
					break;
				}
			}
			if (j == valNum) { //There is not any row that are same with this row, create new row value
				rowValue[valNum] = tmpVal;
				zeroCnt[valNum] = tmpCnt0;
				duplicateCnt[valNum++] = 1;
			}
		}
		int Answer = 0;
		for (j = 0; j < valNum; j++) {
			if (zeroCnt[j] > K || (K - zeroCnt[j]) & 1) //The rows that cannot change to all "1" within K move
				continue;
			if (duplicateCnt[j] > Answer)
				Answer = duplicateCnt[j];
		}
		
		printf("Case #%d %d\n", tc, Answer);
	}

	return 0;
}