#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <queue>
#include <map>
using namespace std;
const int maxn = 2e3+10;
const int mod = 2e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
int n ,m, k, t;
int s[1<<14];
void work()
{
memset(s,0,sizeof(s));
for(int i = 0; i < n; i++){
scanf("%d",&k);
int w = 0;
while(k--){
scanf("%d",&t);
w += 1<<(t - 1);//使用位运算,比如集合里有1,4,5,则w = 11001B
}
s[w] = 1;
for(int i = 1; i < (1<<14); i++){
if(s[i] == 1) //将新输入的集合与之前存在的集合合并
s[w | i] = 1;
}
}
int ans = 0;
for(int i = 1; i < (1<<14); i++){
if(s[i] == 1)
ans++;
}
printf("%d\n",ans);
}
int main()
{
#ifdef LOCAL
freopen("case.in","r",stdin);
// freopen("case.out","w",stdout);
#endif
while(scanf("%d%d",&n,&m) != EOF)
work();
return 0;
}
HDU 3006 位运算
最新推荐文章于 2019-11-06 11:00:28 发布