daocot0110

 avatar
quoc14
c_cpp
19 days ago
21 kB
2
Indexable
Never
Thamlam
Level 7
Đả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.

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


K=2, có 2 hàng toàn 1
0 0 1 0 0
1 1 1 1 1
0 1 1 0 0 
1 1 0 1 1
1 1 1 1 1


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


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
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 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 0
#include <iostream>
using namespace std;

int T, n, m, k, result;
int arr[101][21], temp[101][21];
bool visit[101];

void solveProblem(){
	for(int i = 0; i < n; i++){
		if(visit[i]) continue;
		visit[i] = true;
		int cnt = 1;
		for(int j = i + 1; j < n; j++){
			if(visit[j]) continue;
			bool isSame = true;
			for(int t = 0; t < m; t++){
				if(arr[i][t] != arr[j][t]){
					isSame = false;
					break;
				}
			}
			if(isSame){
				cnt++;
				visit[j] = true;
			}
		}
		int c0 = 0;
		for(int j = 0; j < m; j++){
			if(!arr[i][j]) c0++;
		}
		if((c0 <= k && (k-c0) % 2 == 0)){
			if(result < cnt) result = cnt;
		}
	}
}

int main(){
	freopen("input.txt", "r", stdin);
	cin >> T;
	
	for(int tc = 1; tc <= T; tc++){
		int c0 = 0, c1 = 0;
		// Input
		cin >> n >> m >> k;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin >> arr[i][j];
				if(arr[i][j]) c1++;
				else c0++;
			}
		}
		
		// Initial
		result = 0;
		for(int i = 0; i < n; i++) visit[i] = false;
		
		// Solve Problem
		if((c1 == n*m && k%2 == 0) || (c0 == n*m && k >= m && (k-m)%2 == 0)){
			result = n;
		} else if((c1 == n*m && k%2 == 1) || (c0 == n*m && k < m) || (c0 == n*m && k > m && (k-m)%2 == 1)){
			result = 0;
		} else{
			solveProblem();
		}
		
		// Output
		cout << "Case #" << tc << " " << result << endl;
	}

	return 0;
 }
Leave a Comment