POJ 3274 Gold Balanced Lineup
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 10924 | Accepted: 3244 |
Description
Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For example, cows exhibiting feature #1 might have spots, cows exhibiting feature #2 might prefer C to Pascal, and so on.
FJ has even devised a concise way to describe each cow in terms of its "feature ID", a single K-bit integer whose binary representation tells us the set of features exhibited by the cow. As an example, suppose a cow has feature ID = 13. Since 13 written in binary is 1101, this means our cow exhibits features 1, 3, and 4 (reading right to left), but not feature 2. More generally, we find a 1 in the 2^(i-1) place if a cow exhibits feature i.
Always the sensitive fellow, FJ lined up cows 1..N in a long row and noticed that certain ranges of cows are somewhat "balanced" in terms of the features the exhibit. A contiguous range of cows i..j is balanced if each of the K possible features is exhibited by the same number of cows in the range. FJ is curious as to the size of the largest balanced range of cows. See if you can determine it.
Input
Lines 2..N+1: Line i+1 contains a single K-bit integer specifying the features present in cow i. The least-significant bit of this integer is 1 if the cow exhibits feature #1, and the most-significant bit is 1 if the cow exhibits feature #K.
Output
Sample Input
7 3
7
6
7
2
1
4
2
Sample Output
4
Hint
Source
#include <iostream>
#include <cstring> #include <cstdio> using namespace std; const int MAXHASH=100007; int hash(int v[]) int main() int ans=0; for(int i=1;i<=n;i++) for(int i=2;i<=n;i++) for(int i=0;i<=n;i++) |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )
POJ 3274 Gold Balanced Lineup的更多相关文章
- poj 3274 Gold Balanced Lineup(哈希 )
题目:http://poj.org/problem?id=3274 #include <iostream> #include<cstdio> #include<cstri ...
- POJ 3274 Gold Balanced Lineup(哈希)
http://poj.org/problem?id=3274 题意 :农夫约翰的n(1 <= N <= 100000)头奶牛,有很多相同之处,约翰已经将每一头奶牛的不同之处,归纳成了K种特 ...
- POJ 3274 Gold Balanced Lineup 哈希,查重 难度:3
Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow ...
- POJ 3274:Gold Balanced Lineup 做了两个小时的哈希
Gold Balanced Lineup Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13540 Accepted: ...
- 哈希-Gold Balanced Lineup 分类: POJ 哈希 2015-08-07 09:04 2人阅读 评论(0) 收藏
Gold Balanced Lineup Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13215 Accepted: 3873 ...
- 1702: [Usaco2007 Mar]Gold Balanced Lineup 平衡的队列
1702: [Usaco2007 Mar]Gold Balanced Lineup 平衡的队列 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 510 S ...
- 洛谷 P1360 [USACO07MAR]Gold Balanced Lineup G (前缀和+思维)
P1360 [USACO07MAR]Gold Balanced Lineup G (前缀和+思维) 前言 题目链接 本题作为一道Stl练习题来说,还是非常不错的,解决的思维比较巧妙 算是一道不错的题 ...
- 【POJ】3264 Balanced Lineup ——线段树 区间最值
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 34140 Accepted: 16044 ...
- POJ 题目3264 Balanced Lineup(RMQ)
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 39046 Accepted: 18291 ...
随机推荐
- Openwrt Uboot烧写
Openwrt 烧uboot 需要慎重,一般买一个带不死uboot的路由器再折腾会比较安全,因为 openwrt firmware对uboot分区进行了保护,而且带有不死uboot的路由器可以通过we ...
- memset的使用
今天写程序的时候用了memset这个函数,我知道他是关于清空指针的,设置为0.但我用的时候,没有注意到他是以字节为单位进行操作的,改了半天其他程序内容.要注意的是,memset是对字字进行操作,所以以 ...
- Django1.8教程——从零开始搭建一个完整django博客(二)
在上一节中,我们已经创建了一个Django模型Post,并使Post模型与数据库同步.这一节中,我们将介绍Django管理站点,通过Django管理站点来管理我们创建的Post模型实例. 为你的模型创 ...
- Object C学习笔记14-分类(category)
在.NET中有一个非常带劲的特性,那就是扩展方法. 扩展方法使你能够向现有类型“添加”方法(包括你自定义的类型和对象噢),而无需创建新的派生类型.重新编译或以其他方式修改原始类型.扩展方法是一种特殊的 ...
- 看别人的代码学习的css
<ul class='y1'> <li><a href="#">菜单</a></li> <li ...
- [BZOJ 2186][Sdoi2008]沙拉公主的困惑(欧拉函数)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=2186 分析: 就是要求1~n!中与m!互质的数的个数 首先m!以内的就是φ(m!) 关 ...
- Callable、Future和FutureTask
创建线程的2种方式,一种是直接继承Thread,另外一种就是实现Runnable接口.这2种方式都有一个缺陷就是:在执行完任务之后无法获取执行结果. 如果需要获取执行结果,就必须通过共享变量或者使用线 ...
- Java中唯一数的生成
唯一数的生成很简单,基本上以时间为基础进行生成.在JDK里面已经有java.util.UUID类可以生成唯一的随机数.如果希望生成的唯一数为特定的格式,那么就需要自己来生成唯一数了.生成唯一数时有两个 ...
- ORACLE建表练习
1,学生表 -- Create table create table T_HQ_XS ( xueh ) not null, xingm ) not null, xingb ) ', nianl NUM ...
- Servlet Study 1
this content below are come from the JSR154 by sun Just for record purpose. if this relate to some ...