HDU 3006
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的更多相关文章
- hdu 3006 枚举集合能够产生的全部并集的集合
http://acm.hdu.edu.cn/showproblem.php? pid=3006 刚买的CHERRY键盘 手感真好 可惜不习惯 写代码老是打错.一个题写了一上午,都是各种按错键DEBUG ...
- HDU 3006 The Number of set(位运算 状态压缩)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3006 题目大意:给定n个集合,每个集合都是由大于等于1小于等于m的数字组成,m最大为14.由给出的集合 ...
- HDU - 3006 The Number of set(状态压缩位运算)
http://acm.hdu.edu.cn/showproblem.php?pid=3006 题意 给定n个集合,每个集合都是由大于等于1小于等于m的数字组成,m最大为14.问由给出的集合可以组成多少 ...
- hdu 3006 The Number of set
二进制的状态压缩.比如A集合里面有{1,5,7}那么就表示为1010001.B集合有{3,4},二进制表示1100.A|B=1011101. 按照这样的思路 可以用01背包 把所有的组合全部求出来. ...
- hdu 3006(状态压缩)
The Number of set Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- 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 ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
随机推荐
- Flowplayer-playlist
SOURCE URL: https://flowplayer.org/docs/playlist.html HTML layout Here is a typical setup for a play ...
- 車(rook)
[题目分析] JustPenz:我们假设n>m(不大于就交换),那最多能摆m个,所以会有(n-m)个空白,我们把这些空白插入到n中,答案就是C(n,n-m)=C(n,m);数据范围比较大,我们就 ...
- HTML新手向
一:[什么是HTML] HTML全名是Hyper Test Markup language,是超文本标记语言,用来创建和其他在网页浏览器中看到的信息(由排版语言演变而来)它是用来说明页面排版方式的标记 ...
- 替换 data.frame 中的特殊的值
替换空值: foo <- data.frame("day"= c(1, 3, 5, 7), "od" = c(0.1, "#N/A", ...
- python 中date datetime time 与str的互转
以下全部引入 form datetime import datetime, timedelta import time 一.time 转str 二.datetime 转 str str_date = ...
- NGUI Camera's raycast hit through the UI Layer issue
Raycast into GUI?http://forum.unity3d.com/threads/raycast-into-gui.263397/ << ; Ray myray = UI ...
- 字符串与模式匹配(一)——KMP算法
源码:kmp.cpp // KMP.cpp : Defines the entry point for the console application. // #include "stdaf ...
- GDI+一般性错误(A generic error occurred in GDI+)
1.GDI+的前世今生 GDI+全称图形设备接口,Graphics Device Interface (GDI) ,他的爸爸叫做GDI, 用C写的.Windows XP出来以后用C++重新写了一下,变 ...
- spring随手笔记4:ref的属性
1.local属性 引用在同一个xml的bean 只能引用bean的id <bean id="HelloWord" class="com.ltf ...
- App压力测试整理
压力测试结果:CRASH:崩溃,应用程序在使用过程中,非正常退出ANR:Application Not Responding MonkeyRunner APIs MonkeyRunner:用来连接设备 ...