http://acm.hdu.edu.cn/showproblem.php?pid=3006

注意到集合内数字最大只有14,状态压缩一下,然后枚举出所有状态

#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int dp[<<]; int main() {
int n, m;
while(~scanf("%d%d", &n, &m)) {
memset(dp, , sizeof(dp));
for(int i = ; i < n; i++) {
int k;
scanf("%d",&k);
int s = ;
for(int j = ; j < k; j++) {
int e;
scanf("%d", &e);
s |= (<<(e-));
}
dp[s] = ;
for(int j = ; j < (<<); j++)
if(dp[j])
dp[s|j] = ;
}
int ans = ;
for(int i = ; i < (<<); i++)
if(dp[i]) ans++;
printf("%d\n", ans);
}
return ;
}

HDU 3006的更多相关文章

  1. hdu 3006 枚举集合能够产生的全部并集的集合

    http://acm.hdu.edu.cn/showproblem.php? pid=3006 刚买的CHERRY键盘 手感真好 可惜不习惯 写代码老是打错.一个题写了一上午,都是各种按错键DEBUG ...

  2. HDU 3006 The Number of set(位运算 状态压缩)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3006 题目大意:给定n个集合,每个集合都是由大于等于1小于等于m的数字组成,m最大为14.由给出的集合 ...

  3. HDU - 3006 The Number of set(状态压缩位运算)

    http://acm.hdu.edu.cn/showproblem.php?pid=3006 题意 给定n个集合,每个集合都是由大于等于1小于等于m的数字组成,m最大为14.问由给出的集合可以组成多少 ...

  4. hdu 3006 The Number of set

    二进制的状态压缩.比如A集合里面有{1,5,7}那么就表示为1010001.B集合有{3,4},二进制表示1100.A|B=1011101. 按照这样的思路 可以用01背包 把所有的组合全部求出来. ...

  5. hdu 3006(状态压缩)

    The Number of set Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  6. hdu 3006 The Number of set(思维+壮压DP)

    The Number of set Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  7. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  8. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  9. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

随机推荐

  1. [poj3017] Cut the Sequence (DP + 单调队列优化 + 平衡树优化)

    DP + 单调队列优化 + 平衡树 好题 Description Given an integer sequence { an } of length N, you are to cut the se ...

  2. len字符串的长度

    #!/usr/bin/env python def fun4(x) : if len(x) > 2 : return print(x[0],x[1]) else: return 0 d = (' ...

  3. Java与JavaScript的区别

    (1)执行方式不同 java:是编译语言,需要先编译再执行 JavaScript:无需编译,直接执行 (2)数据类型不同 java:强数据类型语言 JavaScript:弱数据类型语言 (3)运行位置 ...

  4. 访问google.com

    ping www.google.com 得到的IP来访问

  5. redis 库相关命令

    切换数据库: select 1 查看数据库大小:dbsize 清空数据库: flushdb

  6. Android Tips – 填坑手册

    出于: androidChina   http://www.androidchina.net/3595.html 学习 Android 至今,大大小小的坑没少踩,庆幸的是,在强大的搜索引擎与无私奉献的 ...

  7. c++ 文件读写模板

    #include <fstream> using namespace std; int main() { ifstream fin("in.txt"); ofstrea ...

  8. Music Review

    (What do you want to do?)(What do you want to do?)(What do you want to do?)(What is the meaning of l ...

  9. News common vocabulary

    英语新闻常用词汇与短语 经济篇 accumulated deficit 累计赤字 active trade balance 贸易顺差 adverse trade balance 贸易逆差 aid 援助 ...

  10. How do I install Adobe Flash on Debian Wheezy?

    aptitude install flashplugin-nonfreeif fail Check your settings in /etc/apt/sources.list. If this is ...