码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 3006

时间:2015-01-29 19:33:50      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:状态压缩

#include<stdio.h>
#include<string.h>
int mark[1<<16];
int main()
{
	int i,j,n,m,k,t,tot;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		memset(mark,0,sizeof(mark));
		for(i=1;i<=n;i++)
		{
			scanf("%d",&t);
			tot=0;
			for(j=1;j<=t;j++)
			{
				scanf("%d",&k);
				tot=tot|(1<<(k-1));
			}
			mark[tot]=1;
			for(j=1;j<(1<<m);j++)
			{
				if(mark[j])
				{
					mark[j|tot]=1;
				}
			}
		}
		int ans=0;
		for(j=1;j<(1<<(m));j++)
		{
			if(mark[j]) ans++;
		}
		printf("%d\n",ans);
	}
}

HDU 3006

标签:状态压缩

原文地址:http://blog.csdn.net/l133236116/article/details/43274661

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!