题意:
n
n
份答卷个问题 每个问题只有两个答案, 问删去几个问题后还有
k
k
个问卷是不同的
直接二进制枚举答案的子集,用记录一下就好了
#include <bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
const int MAXN = (int)1e3+10;
int n, m, k;
char s[MAXN][11];
int dp[MAXN][11];
int vis[MAXN];
map<int, int> mp;
int main() {
//ios::sync_with_stdio(false);
int T, kk = 0;
scanf("%d",&T);
while(T--) {
cin >> n >> m >> k;
for(int i = 0; i < n; i++) {
scanf("%s", s[i]);
}
int ans = 0;
for(int i = 1; i < 1 << m; i++) {
int zz = 0;
for(int j = 0; j < m; j++) {
if(i & (1 << j)) {
for(int l = 0; l < n; l++) {
dp[l][zz] = s[l][j] - 'A' + 1;
}
zz++;
}
}
memset(vis, 0, sizeof vis);
for(int j = 0; j < n; j++) {
for(int l = 0; l < zz; l++) {
vis[j] <<= 1;
vis[j] |= (dp[j][l] == 1 ? 1 : 0);
}
}
mp.clear();
for(int j = 0; j < n; j++) mp[vis[j]]++;
int tmp = 0;
for(auto it = mp.begin(); it != mp.end(); ++it) {
tmp += (n - it->se) * it->se;
}
if(tmp / 2 >= k) ans++;
}
printf("Case #%d: %d\n", ++kk, ans);
}
return 0;
}