HDU 3116-Bus Schedules-计算几何-[解题报告]HOJ

Bus Schedules

问题描述 :

The Association of Commuters in Montreal (ACM) wishes to create a website for the city’s publictransit commuters, in order to promote public transit. A prominent reason for people to drive to work instead of commuting is the time wasted on the subway and buses. For this reason, the ACM wishes to add a form on their website so that visitors will be able to specify two points on the island, and the website will find the quickest route between those two points using its database of subway and bus schedules.

Seeing how this may help improve the environment and the greenhouse effect, you offer your help.

输入:

The first line of each test case will contain a positive integer n, the number of bus and subway schedules which will follow. Each schedule will begin with a line containing a positive integer m, the number of stops along the path. m lines will follow, describing the stops of the day in chronological order. Each stop will begin by a time in the format hh : mm, between 00 : 00 and 23 : 59 inclusively. There will be at least one minute between each stop ― in other words, all the stop times for a particular bus will be different. A single space will follow, and the rest of the line will contain a name describing the stop.

The name will not contain spaces nor capital letters, and will be at most 20 characters long. Stops with the same name obviously denote the same physical location, where passengers can wait for other buses or subways to stop. After the day completes, the buses and subways mysteriously disappear and reappear at some point before their first stop. They cannot carry any passengers at that time, so the passengers must spend the night waiting at some stop.Each schedule repeats itself every day.

After the schedules, a line will contain a time and two locations of at most 20 characters, the start and the goal. Output the minimum number of minutes needed for a passenger at the start location at the given time to reach the goal location. He is able to enter any bus which stops at his start location at the given starting time or later, and he can also switch from a bus to another instantaneously if they happen to stop at the same place at the same time. He can also wait at a stop for an arbitrary amount of time.

输出:

The first line of each test case will contain a positive integer n, the number of bus and subway schedules which will follow. Each schedule will begin with a line containing a positive integer m, the number of stops along the path. m lines will follow, describing the stops of the day in chronological order. Each stop will begin by a time in the format hh : mm, between 00 : 00 and 23 : 59 inclusively. There will be at least one minute between each stop ― in other words, all the stop times for a particular bus will be different. A single space will follow, and the rest of the line will contain a name describing the stop.

The name will not contain spaces nor capital letters, and will be at most 20 characters long. Stops with the same name obviously denote the same physical location, where passengers can wait for other buses or subways to stop. After the day completes, the buses and subways mysteriously disappear and reappear at some point before their first stop. They cannot carry any passengers at that time, so the passengers must spend the night waiting at some stop.Each schedule repeats itself every day.

After the schedules, a line will contain a time and two locations of at most 20 characters, the start and the goal. Output the minimum number of minutes needed for a passenger at the start location at the given time to reach the goal location. He is able to enter any bus which stops at his start location at the given starting time or later, and he can also switch from a bus to another instantaneously if they happen to stop at the same place at the same time. He can also wait at a stop for an arbitrary amount of time.

At the last minute of the fighting between heroes and Deathwing, who wants to destroy the whole Azeroth, these last guardians of Azeroth are facing a severe test. Deathwing has a powerful AOE (Area of Effect) ability that will kill all lives in a circle of radius R immediately.

In order to help heroes defeat Deathwing, guardian dragons have exhausted all of their mana to restrict Deathwing using his power so that Deathwing can only fire in narrow range. To prevent heroes from danger, Thrall wants to know the area of the region which could be fired by Deathwing. Thrall has labeled the region of the center of Deathwing’s AOE circle, and the important task of saving the world is counting on you. The description of the region consist of several arcs, and these arcs connected end to end to form the boundary of the region. In order to simplify the problem, no tangent of these arcs will intersect with any arc, and the central angle of each arc will less than PI.

Input

There are several tests. For each test case, there are 2 numbers in the first line N and R, indicate the amount of arcs and the radius of AOE. It is followed by N lines, containing 3 numbers(xi, yi and ri) each in counterclockwise order. For i-th arc, (xi, yi) is the coordinate of the starting point , and ri is the radius of curvature. It is obvious that the i-th starting point is the (i-1)-th ending point, and the first starting point is the N-th ending point.

You may assume 1<N<1000, 0<R, ri<1000, -1000<xi, yi<1000.

Output

For each test cases, you need print a number accurate to 0.01 in one line.