Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:谁能讲讲这题怎么贪心吗? 只会用差分约束 (类似1201)

Posted by chenhaifeng at 2006-10-03 15:07:16 on Problem 1716
In Reply To:谁能讲讲这题怎么贪心吗? 只会用差分约束 (类似1201) Posted by:atlas_of_rruucc at 2004-08-03 00:19:31
> 是不是两次对要求"至少为1"的问题进行贪心?
> 用贪心过了的高手能讲讲吗? 先谢过了

  先将区间按左端点Left升序为第一关键字, 右端点Right降序为第二关键字排序。再在线性时间内去除包含关系:即若A包含B,则去除A,因为B满足了,A必然也满足。

       最后贪心,尽量向后安排满足点。设置2根扫描线i, j,表示最后两个满足点,不妨设i < j。从左到右扫描,每找到一个未被满足的区间S,即i<S.Left。若j<S.Left,即i, j都不在区间S中,则设置i, j为S的最后两个数,即i’ = S.Right – 1, j’ = S.Right;否则,即只有j在区间S中,则设置j为S的最后一个数, 即j’ = S.Right,但是要维护i<j的性质,所以令i’ = j。证明方法也很简单,对于任何的最优解,若第一个区间不在两个最右点取,可以调整到这两个最右点,并且解不会更差。所以贪心是正确的。


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator