hdu 3006(状态压缩)
The Number of set
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1301 Accepted Submission(s): 795
not greater than m.If use these sets to combinate the new set,how many
different new set you can get.The given sets can not be broken.
positive integer n and m(1<=n<=100,1<=m<=14).Then the
following n lines describe the n sets.These lines each contains k+1
positive integer,the first which is k,then k integers are given. The
input is end by EOF.
1 1
1 2
1 3
1 4
2 4
3 1 2 3
4 1 2 3 4
2
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define N 14
using namespace std; int a[(<<N)+]; ///14位,最低位存0,2的14次方保存的是 100000000000000可以存15位,所以最大用到 2^14-1 int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
int t,num,k;
memset(a,,sizeof(a));
for(int i=;i<=n;i++){
scanf("%d",&t);
k=;
for(int j=;j<=t;j++){
scanf("%d",&num);
k+=(<<(num-));
}
a[k]=;
for(int j=;j<=(<<N);j++){
if(a[j]){
int next = k|j;
a[next]=;
}
}
}
int ans = ;
for(int i=;i<=(<<N);i++){
if(a[i]) ans++;
}
printf("%d\n",ans);
}
return ;
}
hdu 3006(状态压缩)的更多相关文章
- HDU 1074 (状态压缩DP)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1074 题目大意:有N个作业(N<=15),每个作业需耗时,有一个截止期限.超期多少天就要扣多少 ...
- hdu 4739(状态压缩)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4739 思路:状态压缩. #include<iostream> #include<cs ...
- HDU 3341 状态压缩DP+AC自动机
题目大意: 调整基因的顺序,希望使得最后得到的基因包含有最多的匹配串基因,使得所能达到的智商最高 这里很明显要用状态压缩当前AC自动机上点使用了基因的情况所能达到的最优状态 我最开始对于状态的保存是, ...
- hdu 2167(状态压缩基础题)
题意:给你一个矩阵,让你在矩阵中找一些元素使它们加起来和最大,但是当你使用某一个元素时,那么这个元素周围的其它八个元素都不能取! 分析:这是一道比较基础的状态压缩题,也是我做的第三道状态压缩的题,但是 ...
- hdu 1565(状态压缩基础题)
题意:容易理解. 分析:这是我做的状态压缩第二题,一开始超内存了,因为数组开大了,后来超时了,因为能够成立的状态就那么多,所以你应该先把它抽出来!!总的来说还是比较简单的!! 代码实现: #inclu ...
- HDU 2553 状态压缩
N皇后问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdu 2489(状态压缩+最小生成树)
Minimal Ratio Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- hdu 4033 状态压缩枚举
/* 看别人的的思路 搜索搜不出来我太挫了 状态压缩枚举+好的位置 */ #include<stdio.h> #include<string.h> #define N 20 i ...
- HDU 4856 (状态压缩DP+TSP)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4856 题目大意:有一个迷宫.迷宫里有些隧道,每个隧道有起点和终点,在隧道里不耗时.出隧道就耗时,你的 ...
随机推荐
- 简单理解DES加密算法
数据加密标准(Data Encryption Standard,DES)是当前使用最广泛的加密体制,对于任意的加密方案,总有两个输入:明文和密钥. 明文是64bits,密钥是56bits 加密过程就是 ...
- 图书 Framework 设计指南: 可重用 .NET 库的约定、惯用法和模式 引出资料
文章:框架设计准则 --微软 地址:https://docs.microsoft.com/zh-cn/dotnet/standard/design-guidelines/index
- Mac下使用Charles抓包Android
原文地址:http://fanjiajia.cn/2018/11/21/Mac%E4%B8%8B%E4%BD%BF%E7%94%A8Charles%E6%8A%93%E5%8C%85Android/ ...
- Hadoop2.6.0 完全分布式搭建
1 搭建这个完全分布式的前提环境: 配置好了jdk环境 配置好了ssh免密码登录(详见我的另外一篇博客,专门说ssh免密码登录) 我这里设置了四台机器,一台做master,另外三台做slave,hos ...
- C++陷阱系列:让面试官倒掉的题
http://blog.chinaunix.net/uid-22754909-id-3969535.html 今天和几位同仁一起探讨了一下C++的一些基础知识,在座的同仁都是行家了,有的多次当过C++ ...
- LevelDB速记
LevelDb的基本结构如下: 由六大部分组成: 一.MemTable,用户写入和读取的直接对象, 二.Immutable MemTable,用户状态写入的对象写满的MemTable之后会转为Immu ...
- javasisst & JAVA8
今天在服务器上启动tomcat7的时候,提示如下异常: java.io.IOException: invalid constant type: 15 具体看是javasisst抛出来的. 系统运行环境 ...
- 【bzoj4627】[BeiJing2016]回转寿司 离散化+树状数组
题目描述 给出一个长度为n的序列,求所有元素的和在[L,R]范围内的连续子序列的个数. 输入 第一行包含三个整数N,L和R,分别表示寿司盘数,满意度的下限和上限. 第二行包含N个整数Ai,表示小Z对寿 ...
- HDU4280:Island Transport(最大流)
Island Transport Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- The 'brew link' step did not complete successfully
在mac 上更新node时遇到了一系列的问题: 卸载node重新安装之后提示: The 'brew link' step did not complete successfully 其实这里已经给出了 ...