ZOJ 2770火烧连营——差分约束】的更多相关文章

偶尔做了一下差分约束. 题目大意:给出n个军营,每个军营最多有ci个士兵,且[ai,bi]之间至少有ki个士兵,问最少有多少士兵. --------------------------------------------------- 差分约束:就是利用多个不等式来推导另一个不等式. 由于不等式a-b<=c和求最短路径时的三角形不等式相同,就变成了求最短路. 所有不等式化为a-b<=c的形式,则建造b到a的边,权为c. 求a到b的最短距离,则转化为b-a<=c,距离的值为c. 该题中:…
题目来源:ZOJ Monthly, October 2006, ZOJ2770题目描述:大家都知道,三国时期,蜀国刘备被吴国大都督陆逊打败了.刘备失败的原因是刘备的错误决策.他把军队分成几十个大营,每个大营驻扎一队部队,又用树木编成栅栏,把大营连成一片,称为连营.让我们回到那个时代.陆逊派了很多密探,获得了他的敌人-刘备军队的信息.通过密探,他知道刘备的军队已经分成几十个大营, 这些大营连成一片 (一字排开), 这些大营从左到右用 1…n 编号.第 i 个大营最多能容纳 Ci 个士兵.而且通过观…
题目链接: POJ:http://poj.org/problem?id=1201 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1384 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=508 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1770 题目大意: 陆逊为了火烧连营七百里,派出了间谍刺探敌情,得之刘备的军营以1~n编号一字排开,第i个大营最多能容纳Ci个士兵.而且通过观察刘备军队的动静,陆逊可以估计到从第i个大营到第j个大营至少有多少士兵.最后,陆逊必须估计出刘备最少有多少士兵,这样他才知道要派多少士兵去烧刘备的大营.为陆逊估计出刘备军队至少有多少士兵.然而,陆逊的估计可能不是很精确,如果不能很精确地估…
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemCode=2770 Burn the Linked Camp Time Limit: 2 Seconds      Memory Limit: 65536 KB It is well known that, in the period of The Three Empires, Liu Bei, the emperor of the Shu Empire, was defeat…
It is well known that, in the period of The Three Empires, Liu Bei, the emperor of the Shu Empire, was defeated by Lu Xun, a general of the Wu Empire. The defeat was due to Liu Bei's wrong decision that he divided his large troops into a number of ca…
// 差分约束系统// 火烧连营 // n个点 m条边 每天边约束i到j这些军营的人数 n个兵营都有容量// Si表示前i个军营的总数 那么 1.Si-S(i-1)<=C[i] 这里 建边(i-1,i) 权值为 C[i]// 2.S(i-1)-Si<=0 这里 建边(i,i-1) 权值为 0// 3.S(j)-S(i-1)>=k => S(i-1)-Sj<=-k 这里建边 (j,i-1) 权值为 -k// 题目求的事 Sn-S0的最小值 Sn-S0>=m 中符合条件的m…
Intervals Time Limit: 10 Seconds      Memory Limit: 32768 KB You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: > reads the number of intervals, their endpoints and integers c1, ..., cn from the stand…
原题:ZOJ 3668 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3668 典型差分约束题. 将sum[0] ~ sum[n] 作为节点,A<=sum[R]-sum[L-1]<=B可以分别建边: x(L-1)-->xR  w = B xR --> x(L-1)  w = -A 注意还有 -10000<=sum[i]-sum[i-1]<=10000 (for i in (2,n)),所以相邻点…
Time Limit: 1500MS Memory Limit: 131072K Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse's class a large bag of candies and had flymouse distribute them. All…