HBC24123等和数列[USACO 2011 Nov G]Cow Steeplechase题解

回忆凄美了谁 算法基础篇 32 0
想要成为编程高手?那就来试试全网最全C++题库,让您在练习中快速成长。
Farmer John has a brilliant idea for the next great spectator sport: Cow Steeplechase!As everyone knows, regular steeplechase involves a group of horses that race around a course filled with obstacles they must jump over. FJ figures the same contest should work with highly-trained cows, as long as the obstacles are made short enough. In order to design his course, FJ makes a diagram of all the N (1

Farmer John has a brilliant idea for the next great spectator sport: Cow Steeplechase! As everyone knows, regular steeplechase involves a group of horses that race around a course filled with obstacles they must jump over. FJ figures the same contest should work with highly-trained cows, as long as the obstacles are made short enough. In order to design his course, FJ makes a diagram of all the N (1 <= N <=250) possible obstacles he could potentially build. Each one is represented by a line segment in the 2D plane that is parallel to the horizontal or vertical axis. Obstacle i has distinct endpoints (X1i,Y1i)(X1_i, Y1_i)(X1i​,Y1i​) and (X2i,Y2i)(X2_i,Y2_i)(X2i​,Y2i​) (1<=X1i,Y1i,X2i,Y2i<=1,000,000,000)(1 <= X1_i, Y1_i, X2_i, Y2_i <= 1,000,000,000)(1<=X1i​,Y1i​,X2i​,Y2i​<=1,000,000,000). An example is as follows:    --+------- -----+-----   ---+---     |      |     |  |    --+-----+--+-   |      |     |  |  | |      |   --+--+--+-+-            |  |  | |               | FJ would like to build as many of these obstacles as possible, subject to the constraint that no two of them intersect. Starting with the diagram above, FJ can build 7 obstacles:    ----------    -----------   -------     |            |  |            |  |    |            |  |  | |            |  |  | |            |  |  | |               | Two segments are said to intersect if they share any point in common, even an endpoint of one or both of the segments.  FJ is certain that no two horizontal segments in the original input diagram will intersect, and that similarly no two vertical segments in the input diagram will intersect. Please help FJ determine the maximum number of obstacles he can build.

HBC24123等和数列[USACO 2011 Nov G]Cow Steeplechase题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断学习,不断挑战,才能在编程领域中脱颖而出!全网最全C++题库,助您成为编程高手!

标签: HBC24123等和数列[USACO 2011 Nov G]Cow Steeplechase题解