[C++] 纯文本查看 复制代码 #include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 110;
int a[MAXN] = {0};
int main() {
freopen("toy.in", "r", stdin);
freopen("toy.out", "w", stdout);
int n, m, k;
cin >> n >> m >> k;
for (int i = 0;i < n; ++i) {
int tp;
cin >> tp;
int tmp;
for (int j = 0;j < tp; ++j) {
cin >> tmp;
a[i] = a[i] | (1 << (tmp - 1));
}
}
int ans = 0;
for (int i = 0;i < (1 << k); ++i) {
int tot = 0;
for (int j = 0;j < k; ++j) {
if ((1 << j) & i) {
tot++;
}
}
if (tot > m) {
continue;
}
tot = 0;
for (int j = 0;j < n; ++j) {
if ((a[j] & i) == a[j]) {
tot++;
}
}
ans = max(ans, tot);
}
cout << ans << endl;
return 0;
}
|