Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
1
Indexable
Never
#include<iostream>
using namespace std;

int n, m, k, arr[1000][1000];

int count_row(int h){
	int ans = 0;
	for(int i = 0; i < n; i++){
		int dem = 0;
		for(int j = 0; j < m; j++){
			if(arr[i][j] == arr[h][j]) dem++;
		}
		if(dem ==m) {
			ans++;
		}
	}

	return ans;
}

int count_row_one(){
	int ans = 0;
	for(int i = 0; i < n; i++){
		int dem = 0;
		for(int j = 0; j < m; j++){
			if(arr[i][j] == 1) dem++;
		}
		if(dem ==m) {
			ans++;
		}
	}
	return ans;
}

int main(){
	//freopen("input.txt", "r", stdin);
	int T; cin >> T;
	for(int tc = 1; tc <= T;tc++){
		cout << "Case #" << tc << " ";
		cin >> n >> m >> k;
		for(int i  = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin >> arr[i][j];
			}
		}
		int kq = 0;
		for(int i = 0; i < n; i++){
			int cnt_zero = 0;
			int cnt_one = 0;
			for(int j = 0; j < m; j++){
				if(arr[i][j] == 0) cnt_zero++;
				if(arr[i][j] == 1) cnt_one++;
			}
		
			if(cnt_zero != 0){
				if(k >= cnt_zero && (k-cnt_zero)%2 == 0 ){
				
					if(kq < count_row(i)) kq = count_row(i); 
				}
		
			
			}
			if(cnt_one == m){
				if(kq < count_row_one()){
					kq = count_row_one();
				}
			}
			
		}
		cout << kq << endl;
	}	

	return 0;
}