状态压缩。

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

#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. python2.x 使用protobuf

    1.在windows下配置protobuf 1.1 下载对应的包,包含两个:protoc.exe和源码文件(protoc也可以自己生成) 下载地址1 --- google code最近在迁移,也许以后 ...

  2. html 背景透明文字不透明

    .alpha{ width: 100px; height: 100px; color: #fff; background: rgba(0, 0, 0, .3); filter: progid:DXIm ...

  3. 1988: Sn 爆long long 的处理方法

    题目描述 给你两个数 n, p(0 < n,p <= 10^15); a1 = 1;  a2 = 1+2;  a3 = 1+2+3;  ... an = 1+2+3+...+n    Sn ...

  4. 50条规则提高PHP开发提高效率技巧

    0.用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作 参数的“函数”(译注:PHP手 ...

  5. sql 日结

    --生成日结数据 ==================================== -- Author: <Author,,Name> -- Create date: <Cr ...

  6. Box2d FilterData

    Box2D.Dynamics.b2ContactFilter类,碰撞源码: public virtual function ShouldCollide(fixtureA:b2Fixture, fixt ...

  7. ARP/代理ARP

    1.ARP首先讲到ARP,ARP是地址解析协议,它的作用是在以太网环境下,通过3层的IP地址来找寻2层的MAC地址,得到一张ARP缓存表.转发数据的时候根据ARP缓存表来进行传输.下图详细说明数据传输 ...

  8. Dev之ChartControl控件(二)— 绘制多重坐标图形

    有时针对一个ChartControl控件可能要设置多个Y轴,进行显示: 以下举个例子:如在一个Chart中显示多个指标项如图: 首先,读取数据,并对左边的Y轴最大和最小值进行设定 IndexSerie ...

  9. Servlet程序开发-- 取得其他内置对象

    servlet本身提供的只有request和response对象,如果要取得session对象,只能依靠request对象,因为session属于HTTP协议范畴,而且在每次发送请求的时候,服务器都会 ...

  10. js数据显示在文本框中(页面加载显示和按钮触动显示)

    web代码如下: <!DOCTYPE html> <html> <head> <title>jsTest02.html</title> &l ...