HUST 1371 Emergency relief
状态压缩。
每一个人所需的物品对应一个数字,统计一个每个数字有几个。每一种提供物品的状态也对应一个数字,然后暴力判断。
#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的更多相关文章
- 1003. Emergency (25)
As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...
- Emergency(山东省第一届ACM省赛)
Emergency Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Kudo’s real name is not Kudo. H ...
- HUST 1017 - Exact cover (Dancing Links 模板题)
1017 - Exact cover 时间限制:15秒 内存限制:128兆 自定评测 5584 次提交 2975 次通过 题目描述 There is an N*M matrix with only 0 ...
- 1003. Emergency
As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...
- ubuntu 16.04 source (HUST and 163)
#HUST deb http://mirrors.hust.edu.cn/ubuntu/ xenial main restricted universe multiverse deb http://m ...
- Dancing Link --- 模板题 HUST 1017 - Exact cover
1017 - Exact cover Problem's Link: http://acm.hust.edu.cn/problem/show/1017 Mean: 给定一个由0-1组成的矩阵,是否 ...
- PAT (Advanced Level) Practise 1003 Emergency(SPFA+DFS)
1003. Emergency (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...
- C3P0连接池问题,APPARENT DEADLOCK!!! Creating emergency..... [问题点数:20分,结帖人lovekong]
采用c3p0连接池,每次调试程序,第一次访问时(Tomcat服务器重启后再访问)都会出现以下错误,然后连接库需要很长时间,最终是可以连上的,之后再访问就没问题了,请高手们会诊一下,希望能帮小弟解决此问 ...
- PAT 解题报告 1003. Emergency (25)
1003. Emergency (25) As an emergency rescue team leader of a city, you are given a special map of yo ...
随机推荐
- 导出Excel数据
先要导入jxl架包,其中的abc.xls为测试Excel,具体代码如下,仅供参考: import java.io.File; import java.io.FileInputStream; impor ...
- dedecms 标签的基本用法
1.关键描述调用标签: <meta name="keywords" content="{:fieldname='keywords'/}"> < ...
- 河南多校大一训练赛 D
题目链接:http://acm.hust.edu.cn/vjudge/contest/125004#problem/D 密码:acm Description If an integer is not ...
- Windows API 之 CreateThread、WaitForSingleObject(未完)
WaitForSingleObject Waits until the specified object is in the signaled state or the time-out interv ...
- git使用之如何将github库下载到本地与如何将代码上传github
git使用之如何将github库下载到本地与如何将代码上传github ---------------------------------------------------------------- ...
- js 常用正则表达式表单验证代码
正则表达式使用详解 简介 简单的说,正则表达式是一种可以用于模式匹配和替换的强有力的工具.其作用如下:测试字符串的某个模式.例如,可以对一个输入字符串进行测试,看在该字符串是否存在一个电话号码模式或一 ...
- 【转】调用getActionBar()报Call requires API level 11 (current min is 8): android.app.Activity#getActionBar
解决办法: 第一种方法:修改AndroidManifest.xml中的minSdkVersion=11 第二种方法: 1.导入android-support-v7-appcompat项目,并将其作 ...
- select标签 样式 及文本有空格
<s:select name="codeid" id="codeid" multiple="false" list="#s ...
- Ubuntu Linux 环境变量
2011年09月17日 Ubuntu 下设置adb环境变量 分类: 同Windows一样,Ubuntu Linux系统包含两类环境变量:系统环境变量和用户环境变量.系统环境变量对所有系统用户都有效,用 ...
- android的m、mm、mmm编译命令的使用
android的m.mm.mmm编译命令的使用 android源码目录下的build/envsetup.sh文件,描述编译的命令 - m: Makes from the top of ...