POJ 3189 Steady Cow Assignment
题目链接
题意:一些牛,每个牛心目中都有一个牛棚排名,然后给定每个牛棚容量,要求分配这些牛给牛棚,使得所有牛对牛棚的排名差距尽量小
思路:这种题的标准解法都是二分一个差值,枚举下界确定上界,然后建图判断,这题就利用最大流进行判断,值得一提的是dinic的效率加了减枝还是是卡着时间过的,这题理论上用sap或者二分图多重匹...
分类:
其他好文 时间:
2014-11-07 23:31:18
阅读次数:
412
问题描述:int*cow=newint[n+1];memset(cow,0,(n+1)*4);将N+1个元素置成0,为什么不行memset是对一个字节的int4个字节,因此*4但是只能为0,其他例如1就不可以,详见最后一个例子memest原型(pleasetype"manmemset"inyourshell)void*memset(void*s,intc,size_tn);memset:作用是在一段..
分类:
其他好文 时间:
2014-11-07 19:17:32
阅读次数:
237
Fliptile
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 3487
Accepted: 1351
Description
Farmer John knows that an intellectually satisfied cow is a happ...
分类:
其他好文 时间:
2014-11-07 19:10:01
阅读次数:
193
http://poj.org/problem?id=3617Best Cow LineTime Limit:1000MSMemory Limit:65536KTotal Submissions:10603Accepted:3187DescriptionFJ is about to take hisN...
分类:
其他好文 时间:
2014-11-07 18:32:40
阅读次数:
234
题意:给一个有向图,边严格由编号小的点到编号大的点,现在计数所有的极大路径,求每条边遍历次数的最大值。
题解:正着扫一遍,倒着扫一遍,dp值相乘。
#include
#include
#include
#define N 5050
#define M 50500
using namespace std;
struct KSD
{
int v,next;
long long cnt;
...
分类:
其他好文 时间:
2014-11-07 16:59:33
阅读次数:
225
DescriptionFJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' cow gives: half of the cows give as muc...
分类:
其他好文 时间:
2014-11-07 16:33:31
阅读次数:
170
解题思路:
1.简单动态规划。基本思想是用小的二叉树去组成大的二叉树,最后输出dp[k][n]-dp[k-1][n]恰好就是要求的n个
点组成深度最多为k的方法数
2.设dp[i][j]表示j个点组成深度最多为i的二叉树的方法数,则动态规划公式为:
dp[i][j]=∑(dp[i-1][l]*dp[i-1][j-1-l])(1<=l<=j-2)
dp[i][1]=1
3.注意:点的个数总为奇数。...
分类:
其他好文 时间:
2014-11-07 09:51:47
阅读次数:
191
继承的一个结果是派生于基类的类在方法和属性上有一定的重叠, 【从同一个基类派生出来的多个子类在方法和属性上有重叠】因此,可以使用相同的语法处理从同一个基类实例化的对象。例如,如果基类Animal有一个方法EatFood(),则从派生于它的类Cow和Chicken中调用这个方法,其语法是类似的:Co....
分类:
其他好文 时间:
2014-11-06 23:16:48
阅读次数:
120
DescriptionFarmer John'sN(1 ≤N≤ 10,000) cows are lined up to be milked in the evening. Each cow has a unique "grumpiness" level in the range 1...100,0...
分类:
其他好文 时间:
2014-11-05 16:53:49
阅读次数:
204
The Cow LexiconTime Limit:2000MSMemory Limit:65536KTotal Submissions:7909Accepted:3711DescriptionFew know that the cows have their own dictionary with...
分类:
其他好文 时间:
2014-11-05 12:40:48
阅读次数:
170