Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
2
Indexable
#include<iostream>
using namespace std;
int n,k,m,ans,ans1;
int a[105][105],vis[100];
int b[100],c[100];
bool check(int aa, int bb){
	for(int i =0;i<m;i++){
		if(a[aa][i]!=a[bb][i]) return false ;
	}
	return true;
}
int demso(int k){
	int cnt=0;
	for(int i =0;i<m;i++){
		if(a[k][i]==0) cnt++;
	}
	return cnt;
}
int main(int argc, char** argv)
{
	int test_case;
	int T;

	ios::sync_with_stdio(false);

	//freopen("input.txt", "r", stdin);
	cin >> T;
	for(test_case = 1; test_case <= T; ++test_case)
	{  ans=0;
		cin >> n >> m >> k;
		for(int i =0;i<n;i++){
			vis[i]=0;
			b[i]=0;
			c[i]=0;
			for(int j=0;j<m;j++){
				cin >> a[i][j];
			}
		}
		int dem=0;
		for(int i =0;i<n;i++){
			int ans1=1;
			if(vis[i]==0){
				for(int j=i+1;j<n;j++){
					if(check(i,j)){
						ans1++;
						vis[j]=1;
					}
				}
				c[dem]=ans1;
				b[dem]= demso(i);
				dem++;
			}
		}
		for(int i =0;i<dem;i++){
			if(k >= b[i]){
				if((k-b[i])%2==0) ans = max(ans,c[i]);
			}
			else {
				c[i]=0;}

		}
		
		cout << "Case #" << test_case << " " << ans << endl;
	}
	return 0;//Your program should return 0 on normal termination.
}