Is the Information Reliable?(差分约束)
摘要:DescriptionThe 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 withNdefense stations. Because of the cooperation of the stations, Zibu’s Marine Glory cannot march any further but stay out
阅读全文
posted @
2013-11-29 21:48
straw_berry
阅读(272)
推荐(0)
King(差分约束)
摘要:http://poj.org/problem?id=1364题意真心看不大懂啊。。。现在假设有一个这样的序列,S={a1,a2,a3,a4...ai...at}其中ai=a*si,其实这句可以忽略不看现在给出一个不等式,使得ai+a(i+1)+a(i+2)+...+a(i+n)ki首先给出两个数分别代表S序列有多少个,有多少个不等式不等式可以这样描述给出四个参数第一个数i可以代表序列的第几项,然后给出n,这样前面两个数就可以描述为ai+a(i+1)+...a(i+n),即从i到n的连续和,再给出一个符号和一个ki当符号为gt代表‘>’,符号为lt代表‘02 2 lt 2a2+a3+a40
阅读全文
posted @
2013-11-26 20:02
straw_berry
阅读(326)
推荐(0)
Intervals(差分约束)
摘要:http://poj.org/problem?id=1201题意:给出N个整数区间[ai,bi],并且给出一个约束ci,( 1= ci个,求出数组Z的最小长度。思路:建立差分约束系统。因为这里要求数组长度的最小值,要变为x-y>=k的标准形式。设数组 s[j] 表示数组 Z 区间[0,j]里包含的元素个数。所以 s[bi+1] - s[ai] >= ci,注意是 j+1,隐含条件 0 = ci;s[i+1] - s[i] >= 0;s[i] - s[i+1] >= -1;然后邻接表建图求最长路。 1 #include 2 #include 3 #include 4 #i
阅读全文
posted @
2013-11-24 19:31
straw_berry
阅读(456)
推荐(0)
Candies(差分约束)
摘要:http://poj.org/problem?id=3159题意:flymouse是幼稚园班上的班长,一天老师给小朋友们买了一堆的糖果,由flymouse来分发,在班上,flymouse和snoopy是死对头,两人势如水火,不能相容,因此fly希望自己分得的糖果数尽量多于snoopy,而对于其他小朋友而言,则只希望自己得到的糖果不少于班上某某其他人就行了。比如A小朋友强烈希望自己的糖果数不能少于B小朋友m个,即B- A 2 #include 3 #include 4 using namespace std; 5 6 const int INF = 0x3f3f3f3f; 7 const in.
阅读全文
posted @
2013-11-22 22:01
straw_berry
阅读(335)
推荐(0)