【poj2588】Snakes

2014年3月19日1,1640

Description

Buffalo Bill wishes to cross a 1000×1000 square field. A number of snakes are on the field at various positions, and each snake can strike a particular distance in any direction. Can Bill make the trip without being bitten?

Input

Assume that the southwest corner of the field is at (0,0) and the northwest corner at (0,1000). The input consists of a line containing n <= 1000, the number of snakes. A line follows for each snake, containing three real numbers: the (x,y) location of the snake and its strike distance. The snake will bite anything that passes closer than this distance from its location.

Output

Bill must enter the field somewhere between the southwest and northwest corner and must leave somewhere between the southeast and northeast corners. 

If Bill can complete the trip, give coordinates at which he may enter and leave the field. If Bill may enter and leave at several places, give the most northerly. If there is no such pair of positions, print “Bill will be bitten.”

Sample Input

Sample Output

题解

复制一份嘿嘿嘿

这样处理以后如果有从左到右的路径,当且仅当不存在S到T通路!只要深搜或者广搜即可!但是题目还要我们求出左右的坐标,只需确定纵坐标即可,而且纵坐标要最大!所以我们考虑与S连通的每一个点,如果该点代表的圆与左边界有交点,那么如果从这个交点上面走一定走不过去,所以我们更新左边的纵坐标到这个交点处,对所有的圆都这样处理,即可确定左边纵坐标,右边的同理可求!而且这一步可以在求连通的时候随便求出,我们只需从S出发,一直搜即可!