描述

In order to celebrate the 8th anniversary of ZOJ, LCLL goes to a sauce factory to "Get Sauce". The factory has N kinds of materials. If we combine some of them, we will get a bottle of sauce. LCLL is a sauce genius, he knows about M ways to make the sauce with these materials. Now LCLL wants to get as many bottles of sauce as possible, but he can use each kind of material only once. How many bottles of sauce will LCLL take home at most?

输入

The input file will contain multiple test cases. Each case contains two integers N and M(0 <=N <= 16, 0<= M <=50,000), then there are M lines, each line describe a way to make sauce like this: K a1,a2...aK where K(1<=K<=N) is the number of kinds of materials, ai is a number between[1,N] represents a kind of material this way needs.

Process to the end-of-file.

输出

For each test case print a single line that contains the number of the bottles of sauce LCLL will get at most.

样例输入

5 3
2 1 2
2 2 3
2 3 4

5 2
1 1
4 1 2 3 4

样例输出

2
1

题目大意:

现在有n种材料(每种只有一个),m种方案,每种方案需要若干种材料,求最多能 完成的方案数。

#include <bits/stdc++.h>
using namespace std;
int dp[<<];
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
memset(dp,,sizeof dp);
int S=(<<n)-;
for(int i=,k;i<=m;i++)
{
scanf("%d",&k);
int s=;
for(int j=,x;j<=k;j++)
scanf("%d",&x),s|=(<<(x-));
int res=S^s;
dp[s]=max(dp[s],);
for(int j=res;j;j=(j-)&res)///遍历res子集
if(dp[j])
dp[s|j]=max(dp[s|j],dp[j]+);
}
int ans=;
for(int i=;i<=S;i++)
ans=max(ans,dp[i]);
printf("%d\n",ans);
}
return ;
}

最新文章

  1. LeetCode 【Single Number I II III】
  2. 【opencv】图片标注文字
  3. freemarker学习
  4. 《WPF程序设计指南》读书笔记——第9章 路由输入事件
  5. ARM架构下linux设备树加载的方法
  6. XJOI网上同步测试DAY14 T1
  7. cocostudio中button
  8. C#基础笔记---浅谈XML读取以及简单的ORM实现
  9. bzoj4819 [Sdoi2017]新生舞会
  10. YYHS-Super Big Stupid Cross(二分+扫描线+平衡树)
  11. 三种读取HashMap的方式
  12. JAVA对象克隆可能会出现的问题
  13. MySql操作(一)
  14. 不用IDE写C#的Hello World
  15. JAVA-JSP内置对象之application对象获得服务器版本
  16. vue 回车自动登录
  17. Fiddler抓包原来可以这么玩
  18. JAVA优化技巧分享 让游戏更加的流畅
  19. PHP error_reporting() 错误控制函数功能详解
  20. Ubuntu下键盘输入错乱问题,输入双引号输出的是@符号,输入#号输出的是未知语言的字符

热门文章

  1. Python3+Selenium3+webdriver学习笔记5(模拟常用键盘和鼠标事件)
  2. 轮播插件unslider.min.js使用demo
  3. HDU 4741 Save Labman No.004 (几何)
  4. Netbackup常用命令--bpdbjobs
  5. C# 控制台应用程序输出颜色字体[更正版]
  6. java基础—异常处理
  7. 16Shell脚本—计划任务服务程序
  8. Python数据分析实战视频教程【小蚊子数据分析实战课程】
  9. 分享几个能用的 editplus 注册码
  10. DeepFaceLab: SSE,AVX, OpenCL 等版本说明!