Cows 题目:http://poj.org/problem?id=2481 题意:有N头牛,每仅仅牛有一个值[S,E],假设对于牛i和牛j来说,它们的值满足以下的条件则证明牛i比牛j强壮:Si <=Sjand Ej <= Ei and Ei - Si > Ej - Sj. 如今已知每一头牛的測验值,要求输出每头牛有几头牛比其强壮. 思路:将牛依照S从小到大排序.S同样依照E从大到小排序,这就保证了排在后面的牛一定不比前面的牛强壮. 再依照E值(离散化后)建立一颗线段树(这里最值仅仅有1…
Cows Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 17626 Accepted: 5940 Description Farmer John's cows have discovered that the clover growing along the ridge of the h…
Description Farmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good. Farmer John has N cows (we number the cows from 1 to N). Ea…
题意:对于两个区间,[si,ei] 和 [sj,ej],若 si <= sj and ei >= ej and ei - si > ej - sj 则说明区间 [si,ei] 比 [sj,ej] 强.对于每个区间,求出比它强的区间的个数. 解题思路:先将每个区间按 e 降序排列,在按 s 升序排列.则对于每个区间而言,比它强的区间的区间一定位于它的前面. 利用数状数组求每个区间[si,ei]前面 满足条件的区间[sj,ej]个数(条件:ej<=ei),再减去前面的和它相同的区间的个…