Dao cot

mail@pastecode.io avatar
unknown
plain_text
a year ago
21 kB
1
Indexable
Never
*** De ***
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


*** input ***

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

*** output ***
Case #1 1
Case #2 2
Case #3 25
Case #4 16
Case #5 19
Case #6 29
Case #7 5
Case #8 1
Case #9 100
Case #10 100

*** my code ***


#include<iostream>
#define MaxN 101

using namespace std;

int N, M, K;
int numRowDifference = 0;
int rowValue[MaxN];
int zeroCnt[MaxN]; // so so 0 trong hang do
int dupCnt[MaxN]; // so hang giong nhau

int main(){
	freopen("input.txt", "r", stdin);
	int TC; cin >> TC;
	int tmpDigit, tmpVal, tmpCnt0;
	int j;
	for (int tc = 1; tc <= TC; tc++){
		cin >> N >> M >> K;
		numRowDifference = 0;
		for (int i = 0; i < N; i++){
			tmpVal = tmpCnt0 = 0;
			// 1. nhap hang
			for (j = 0; j < M; j++){
				cin >> tmpDigit;
				tmpVal = (tmpVal << 1) | tmpDigit; // luu hang duoi dang chuooi nhi phan de luc sau so sanh giong nhau
				if (tmpDigit == 0) tmpCnt0++;
			}
			// 2. So sanh hang vua nhap voi cac hang truoc do
			for (j = 0; j < numRowDifference; j++){
				if (tmpVal == rowValue[j]){
					dupCnt[j]++;
					break;
				}
			}
			// 3. neu khong trung voi hang nao thi tao hang moi
			if (j == numRowDifference){
				rowValue[j] = tmpVal;
				zeroCnt[j] = tmpCnt0;
				dupCnt[numRowDifference++] = 1;
			}
		}
		// kiem tra tung hang trong mang luu cac hang khac biet nhau
		int ans = 0;
		for ( j = 0; j < numRowDifference; j++){
			// so so 0 lon hon K
			if (zeroCnt[j] > K) continue;
			// K-cnt0 la so le
			if (K - zeroCnt[j] & 1) continue;
			// co the full 1
			else {
				// cap nhat gia tri lon nhat
				if (dupCnt[j] > ans) ans = dupCnt[j];
			}
		}
	
		cout << "Case #" << tc << " " << ans << endl;
	}
	return 0;
}