状态压缩。

每一个人所需的物品对应一个数字,统计一个每个数字有几个。每一种提供物品的状态也对应一个数字,然后暴力判断。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; const int maxn = ;
int n, m, k;
int tot[maxn];
int ans;
int base[], y; int main()
{ while (~scanf("%d%d%d", &n, &m, &k)){
memset(tot, , sizeof tot); ans = ;
for (int i = ; i <= k; i++)
{
int t; scanf("%d", &t);
int state = ;
for (int j = ; j <= t; j++)
{
int x; scanf("%d", &x); x--;
state = state + ( << x);
}
tot[state]++;
} for (int i = ; i <= ( << n) - ; i++)
{
int tmp = i; y = ;
while (tmp) base[y++] = tmp % , tmp = tmp / ;
int num = ;
for (int i = ; i < y; i++) if (base[i]) num++;
if (num != m) continue; int ans_now = ;
for (int j = ; j <= i; j++)
if ((j|i)==i)
ans_now = ans_now + tot[j];
ans = max(ans, ans_now);
}
printf("%d\n", ans);
}
return ;
}

HUST 1371 Emergency relief的更多相关文章

  1. 1003. Emergency (25)

    As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...

  2. Emergency(山东省第一届ACM省赛)

    Emergency Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Kudo’s real name is not Kudo. H ...

  3. HUST 1017 - Exact cover (Dancing Links 模板题)

    1017 - Exact cover 时间限制:15秒 内存限制:128兆 自定评测 5584 次提交 2975 次通过 题目描述 There is an N*M matrix with only 0 ...

  4. 1003. Emergency

    As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...

  5. ubuntu 16.04 source (HUST and 163)

    #HUST deb http://mirrors.hust.edu.cn/ubuntu/ xenial main restricted universe multiverse deb http://m ...

  6. Dancing Link --- 模板题 HUST 1017 - Exact cover

    1017 - Exact cover Problem's Link:   http://acm.hust.edu.cn/problem/show/1017 Mean: 给定一个由0-1组成的矩阵,是否 ...

  7. PAT (Advanced Level) Practise 1003 Emergency(SPFA+DFS)

    1003. Emergency (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...

  8. C3P0连接池问题,APPARENT DEADLOCK!!! Creating emergency..... [问题点数:20分,结帖人lovekong]

    采用c3p0连接池,每次调试程序,第一次访问时(Tomcat服务器重启后再访问)都会出现以下错误,然后连接库需要很长时间,最终是可以连上的,之后再访问就没问题了,请高手们会诊一下,希望能帮小弟解决此问 ...

  9. PAT 解题报告 1003. Emergency (25)

    1003. Emergency (25) As an emergency rescue team leader of a city, you are given a special map of yo ...

随机推荐

  1. icecap录屏gif

    百度云下载地址:http://pan.baidu.com/s/1jIeyb4q 之前写博客,只有文字,有些效果看不出来.有了这个gif录屏工具方便很多哦,嘿嘿

  2. 怎样解决VS2013模块对于SAFESEH 映像是不安全的

    今天在使用VS2013编译一个控制台应用程序时出现了:error LNK2026 模块对于 SAFESEH 映像是不安全的,按照以下步骤轻松解决了. 打开该项目的“属性页”对话框,然后单击“链接器”- ...

  3. DrawerLayout和ActionBarDrawerToggle

    说明:DrawerLayout的作用就是左侧滑出.右侧滑出菜单.需要和ActionBarDrawerToggle来配合使用.如果对ActionBar不理解,请先熟悉ActionBar. 1.首先配置D ...

  4. C++builder编译别人工程报错

    编译时遇到错误,信息如下: [C++ Error] NVRAMEditor.h(83): E2209 Unable to open include file 'CONTROLSLib_OCX.h'[C ...

  5. SQL Server 自定义快捷键

    SQL Server程序员经常要在SSMS(SQL Server Management Studio)或查询分析器(2000以前)中编写T-SQL代码.以下几个技巧,可以提升工作效率. 以下说明以SS ...

  6. Linux学习 -- Shell编程 -- 字符截取命令

    cut字段提取命令 cut [选项] 文件名 -f 列号: -d 分隔符: 局限性:空格为分隔符时不适用 printf命令 printf '输出类型输出格式' 输出内容 %s, %i, %f \a, ...

  7. try...catch...finally...return的四角恋

    java里的try...catch...finally的三角恋关系众多程序员必然是不陌生的.但是他们三者再加上一个return的话,就会难倒一大片人吧.以前就对这个知道这个问题,没系统的总结一下,结果 ...

  8. Windows下MongoDB安装及创建用户名和密码

    下载MongoDB的安装文件https://www.mongodb.com/download-center#community,选择合适的版本(注:本人选择的是3.2.6) 下载完MongoDB.ms ...

  9. Why attitude is more important than IQ

    原文:http://www.businessinsider.com/why-attitude-is-more-important-than-iq-2015-9?IR=T& LinkedIn I ...

  10. Java中使用poi导入、导出Excel

    一.介绍 当前B/S模式已成为应用开发的主流,而在企业办公系统中,常常有客户这样子要求:你要把我们的报表直接用Excel打开(电信系统.银行系统).或者是:我们已经习惯用Excel打印.这样在我们实际 ...