http://acm.hdu.edu.cn/showproblem.php?pid=1531 King Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1992    Accepted Submission(s): 928 Problem Description Once, in one kingdom, there was a quee…
Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5273    Accepted Submission(s): 1680 Problem Description One day , Kiki wants to visit one of her friends. As she is liable…
King Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8660   Accepted: 3263 Description Once, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: ``If my child was a son and if only he was a sound king…
题意 有n个数的序列, 下标为[1.. N ], 限制条件为: 下标从 si 到 si+ni 的项求和 < 或 > ki. 一共有m个限制条件. 问是否存在满足条件的序列. 思路 转化为差分约束, 就是 即 Si 为第 i 项的前缀和, 特别的 So 为0. 转化不等式(连续子段和变为前缀和之差 > < 变为 >= <= ),求最短路, 判断有没有负权回路. 注意 由于并不知道图是否连通 (不像是之前的那道Candies图一定是联通的,选择班长所代表的点即可) 所以正常…
King Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14791   Accepted: 5226 Description Once, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: ``If my child was a son and if only he was a sound kin…
Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a straight line waiting for feed. The cows are standing in the same order as they are numbered, and sin…
题目链接:https://cn.vjudge.net/contest/276233#problem/D 具体大意: 给出n个闭合的整数区间[ai,bi]和n个整数c1,-,cn. 编写一个程序: 从标准输入中读取间隔数,它们的端点和整数c1,-,cn, 计算具有间隔[ai,bi]的至少ci共同元素的整数集合Z的最小尺寸,对于每个i = 1,2,-,n, 将答案写入标准输出. 具体思路:首先,我们假设存在一个数组s,s[i]记录的是第i个点到第0个点的需要取出的点的个数,对于题目中的从(A,B)至…
Description The galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line with N defense stations. Because of the cooperation of the stations, Zibu…
怎么搞?        1. 如果要求最大值      想办法把每个不等式变为标准x-y<=k的形式,然后建立一条从y到x权值为k的边,变得时候注意x-y<k =>x-y<=k-1     将这些约束条件转化为差分约束,不妨设T[x] = S[1]+S[2]+....S[x],那么上面式子就可以转化为:         1. T[si+ni] - T[si-1] > ki          2. T[si+ni] - T[si-1] < ki          又差分约…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1531 差分约束的题之前也碰到过,刚好最近正在进行图论专题的训练,就拿来做一做. ①:对于差分不等式,a - b <= c ,建一条 b 到 a 的权值为 c 的边,求的是最短路,得到的是最大值 ②:对于不等式 a - b >= c ,建一条 b 到 a 的权值为 c 的边,求的是最长路,得到的是最小值 ③:存在负环的话是无解 .④:求不出最短路(dist[ ]没有得到更新)的话是任意解 说明一下为…