Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
20 kB
0
Indexable
Never
Đảo Cột
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.


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


code:

#include <iostream>

using namespace std;

int main(){

	int t;
	cin >> t;
	for(int tc = 1; tc <= t;tc++){
		int n,m,k;
		
		cin >> n >> m >> k;
		int arr[100][20] = {0};
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin >> arr[i][j];
			}
		}
		int ans = 0;
		for(int i = 0; i < n; i++){     // duyet tung hang
			int dem_so0 = 0;
			for(int j = 0; j < m; j++){   // dem so phan tu = 0 trong tung hang
				if(arr[i][j] == 0){
					dem_so0++;
				}
			}
			if( k >= dem_so0 && (k-dem_so0) % 2 == 0){
				int dem_giong_hang = 0;
				for(int is = 0; is < n; is++){
					int dem_giong = 0;
					for(int j = 0; j < m; j++){   
						if(arr[is][j] == arr[i][j]){
							dem_giong++;
						}
					}
					if(dem_giong == m){
						dem_giong_hang++;
					}
					if(ans <= dem_giong_hang){
						ans = dem_giong_hang;
					}
				}
			}
		}
		cout << "case" << " "<< "#" << tc << " " << ans << endl;
	}
	return 0;
}