Đả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
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
#include <iostream>
using namespace std;
int n, m, k;
int arr[101][101];
int Max;
void Doi(int cot){
for(int i=1; i<=n; i++){
arr[i][cot] = 1 - arr[i][cot];
}
}
int DemHang(){
int count = 0;
for(int i=1; i<=n; i++){
bool flag = true;
for(int j=1; j<=m; j++){
if(arr[i][j] != 1){
flag = false;
break;
}
}
if(flag)
count++;
}
return count;
}
void BackTrack(int cot, int dem){
if(cot == m+1 || dem == k){
if((k - dem)%2==0){
Max = max(Max, DemHang());
}
return;
}
for(int i=0; i<=1; i++){
if(i==0){
BackTrack(cot+1, dem);
}
if(i==1){
Doi(cot);
BackTrack(cot+1, dem+1);
Doi(cot);
}
}
}
int main(){
//freopen("vao.txt", "r", stdin);
int t;
cin >> t;
for(int tc=1; tc<=t; tc++){
cin >> n >> m >> k;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
cin >> arr[i][j];
}
}
Max = -1;
BackTrack(1, 0);
cout << "Case #" << tc << " ";
cout << Max << endl;
}
return 0;
}