1688: [Usaco2005 Open]Disease Manangement 疾病管理( 枚举 )
我一开始写了个状压dp..然后没有滚动就MLE了...
其实这道题直接暴力就行了... 2^15枚举每个状态, 然后检查每头牛是否能被选中, 这样是O( 2^15*1000 ), 也是和dp一样的时间复杂度....有点贪心的feel
------------------------------------------------------------------------------
------------------------------------------------------------------------------
1688: [Usaco2005 Open]Disease Manangement 疾病管理
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 423 Solved: 281
[Submit][Status][Discuss]
Description
Alas! A set of D (1 <= D <= 15) diseases (numbered 1..D) is running through the farm. Farmer John would like to milk as many of his N (1 <= N <= 1,000) cows as possible. If the milked cows carry more than K (1 <= K <= D) different diseases among them, then the milk will be too contaminated and will have to be discarded in its entirety. Please help determine the largest number of cows FJ can milk without having to discard the milk.
Input
* Line 1: Three space-separated integers: N, D, and K * Lines 2..N+1: Line i+1 describes the diseases of cow i with a list of 1 or more space-separated integers. The first integer, d_i, is the count of cow i's diseases; the next d_i integers enumerate the actual diseases. Of course, the list is empty if d_i is 0. 有N头牛,它们可能患有D种病,现在从这些牛中选出若干头来,但选出来的牛患病的集合中不过超过K种病.
Output
* Line 1: M, the maximum number of cows which can be milked.
Sample Input
0---------第一头牛患0种病
1 1------第二头牛患一种病,为第一种病.
1 2
1 3
2 2 1
2 2 1
Sample Output
OUTPUT DETAILS:
If FJ milks cows 1, 2, 3, 5, and 6, then the milk will have only two
diseases (#1 and #2), which is no greater than K (2).
HINT
Source
1688: [Usaco2005 Open]Disease Manangement 疾病管理( 枚举 )的更多相关文章
- 1688: [Usaco2005 Open]Disease Manangement 疾病管理
1688: [Usaco2005 Open]Disease Manangement 疾病管理 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 413 So ...
- BZOJ 1688: [Usaco2005 Open]Disease Manangement 疾病管理
Description Alas! A set of D (1 <= D <= 15) diseases (numbered 1..D) is running through the fa ...
- 【BZOJ】1688: [Usaco2005 Open]Disease Manangement 疾病管理(状压dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1688 很水的状压.. 提交了很多次优化的,但是还是100msT_T #include <cst ...
- BZOJ 1688: [Usaco2005 Open]Disease Manangement 疾病管理 状压DP + 二进制 + 骚操作
#include <bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) #defin ...
- 【BZOJ1688】[Usaco2005 Open]Disease Manangement 疾病管理 状压DP
[BZOJ1688][Usaco2005 Open]Disease Manangement 疾病管理 Description Alas! A set of D (1 <= D <= 15) ...
- 【状压dp】【bitset】bzoj1688 [Usaco2005 Open]Disease Manangement 疾病管理
vs(i)表示患i这种疾病的牛的集合. f(S)表示S集合的病被多少头牛患了. 枚举不在S中的疾病i,把除了i和S之外的所有病的牛集合记作St. f(S|i)=max{f(S)+((St|vs(i)) ...
- bzoj1688: [Usaco2005 Open]Disease Manangement 疾病管理
思路:状压dp,枚举疾病的集合,然后判断一下可行性即可. #include<bits/stdc++.h> using namespace std; #define maxs 400000 ...
- [Usaco2005 Open]Disease Manangement 疾病管理 BZOJ1688
分析: 这个题的状压DP还是比较裸的,考虑将疾病状压,得到DP方程:F[S]为疾病状态为S时的最多奶牛数量,F[S]=max{f[s]+1}; 记得预处理出每个状态下疾病数是多少... 附上代码: # ...
- 【bzoj1688】[USACO2005 Open]Disease Manangement 疾病管理
题目描述 Alas! A set of D (1 <= D <= 15) diseases (numbered 1..D) is running through the farm. Far ...
随机推荐
- 74HC595的中文资料
74HC595--具有三态输出锁存功能的8位串行输入.串行/并行输出移位寄存器 本文翻译自NXP的74HC595的datasheet 74HC595和74HCT595是带有存储寄存器和三态输出的8位串 ...
- hdu1281结题报告
哎哎...自己刚刚一看到这个题目居然.....什么都想不到...看了一下别人的解题报告说最大匹配...于是就自己开始构思啦... 对于这个棋盘,有K个可以放棋子的位置....那么 首先我们开始可以求出 ...
- sqlite性能简单測试
主要測试sqlite在大数据量下的插入及查询性能: 測试环境:Centos6.4 1G内存 单核 数据量 大小 索引字段检索(耗时) 非索引字段检索(耗时) 总插入时间 10W 19M 0.001 ...
- iOS开展-CocoaPods安装和使用教程
原文链接: iOS开展-CocoaPods安装和使用教程 修正已经增加了自己的理解. CocoaPods安装和使用教程 Code4App 原创文章.转载请注明出处:http://code4app.co ...
- 【翻译】【中英对照】【企业库6】动手实验 Hands-On Lab 日志应用程序块索引页
Logging Application Block Hands-On Lab for Enterprise Library 企业库的日志应用程序块动手实验 This walkthrough shoul ...
- Chrome插件Visual Event查看Dom元素绑定事件的利器
找这工具找了好久,统一找着了,开发人员不可多得的好东东,收藏做一下分享. 用Chrome插件Visual Event查看Dom绑定的事件 Visual Event简介 Visual Event是一个开 ...
- 重启IIS常见命令
重启IIS常见命令 http://jingyan.baidu.com/article/4ae03de30d6cfa3efe9e6b4a.html
- was服务器下修改jsp无效果
使用了jsp静态导入,修改了导入的jsp页面,但是目标页面没出现效果.先说下静态导入和动态导入的区别: include指令用于引入其它JSP页面,如果使用include指令引入了其它JSP页面,那么J ...
- python网络编程——将IPv4地址转换成不同的格式
1.将IPv4地址转换为32位二进制格式,用做底层网络函数. import socket from binascii import hexlify def convert_IPv4_address() ...
- poj 3286 统计0的个数
#include <iostream> using namespace std; long long p; ]; long long solve(long long n){ ; ;i< ...