状态压缩。

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

#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. SELinux(Security-Enhanced Linux)

    http://blog.csdn.net/myarrow/article/details/9839377 Security-Enhanced Linux(SELinux)的历史 一个小历史将有助于帮助 ...

  2. Monad / Functor / Applicative 浅析

    前言 Swift 其实比 Objective-C 复杂很多,相对于出生于上世纪 80 年代的 Objective-C 来说,Swift 融入了大量新特性.这也使得我们学习掌握这门语言变得相对来说更加困 ...

  3. java断点

    第一步: 用firefox运行程序,当点击保存,提示保存失败后,启动firebug 通过请求找到addNew.ezt出现错误,在eztnews.xml里通过ctrl+F查找找到请求执行的类和方法 找到 ...

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

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

  5. java 对象的组合,一个类组合到另一个类中(例如手机卡装到手机上)

    Example4_9.java public class Example4_9 { public static void main(String args[]) { SIM simOne = new ...

  6. angular实现select的ng-options

    html <div ng-controller="ngSelect"> <select ng-model="vm.selectVal" ng- ...

  7. hibernate不能自动生成表的原因总结

    1. upate->create <property name="hbm2ddl.auto">create</property> 2. 2.Mappi ...

  8. Ubuntu vim显示行号语法高亮自动缩进

    配置文件名为Ubuntu vimrc在Fedora中vim的配置文件存放在/etc目录中,配置文件名为Ubuntu vimrc在终端 输入以下命令来编辑Ubuntu vimrc配置文件:sudo vi ...

  9. 手机电话号码吉凶查询原理及ASP算法源码 转

    随着手机的快速普及,越来越多的人都在使用手机,而号码的挑选也是用户越来越关心的事情.虽然号码只是个代号而已,但几千年的传统积淀仍给号码赋予其各种含义,至于号码的吉凶也是见仁见智的一种个人喜好问题,或许 ...

  10. 转 layout_weight体验(实现按比例显示)

    http://www.cnblogs.com/zhmore/archive/2011/11/04/2236514.html 在android开发中LinearLayout很常用,LinearLayou ...