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 题目大意:有一个迷宫.迷宫里有些隧道,每个隧道有起点和终点,在隧道里不耗时.出隧道就耗时,你的 ...
随机推荐
- POI实现excel的数据验证
目录 前言 难点1:合并单元格 代码实现策略: step 1: 合并单元格 step 2: 给单元格赋值 难点2:数据验证-下拉框 代码实现策略: step 1:设置需要进行数据验证的单元格范围和可供 ...
- HDU 2139 Calculate the formula
http://acm.hdu.edu.cn/showproblem.php?pid=2139 Problem Description You just need to calculate the su ...
- vue里的this
vue中methods对象里的函数, this指向的都是当前实例或者组件.
- vue中表单的动态绑定
有一个表单: <el-form :model="configForm"> </el-form> 如果configForm初始化为{},此对象是动态变化的,如 ...
- [转]网页ContentType详细列表
本文转自:来老师的专栏 http://blog.csdn.net/sweetsoft/article/details/6512050 不同的ContentType 会影响客户端所看到的效果.默认的 ...
- 为Ubuntu安装SSH服务
只有当Ubuntu安装了SSH服务后,我们才能够通过ssh工具登陆Ubuntu.我自己喜欢使用x-shell作为终端工具 1.安装Ubuntu缺省安装了openssh-client,所以在这里就不安装 ...
- CF985F Isomorphic Strings
题目描述 You are given a string s s s of length n n n consisting of lowercase English letters. For two g ...
- 【题解】NOIP2016换教室
哇好开心啊!写的时候真的全然对于这个加法没有把握,但还是大着胆子试着写了一下——竟然过了样例?于是又调了一下就过啦. 不过想想也觉得是正确的吧,互相独立的事件对于期望的影响自然也是相互独立的,可以把所 ...
- POJ 开关问题 解题报告
开关问题 Time Limit: 1000MS Memory Limit: 30000K Description 有N个相同的开关,每个开关都与某些开关有着联系,每当你打开或者关闭某个开关的时候,其他 ...
- Generator的基本用法
Generator函数是一个状态机,封装了多个内部状态.执行一个Generator,会返回一个迭代器对象,通过迭代器对象,可以遍历Generator函数内部的每个状态.因此,Generator函数可以 ...