Fludtown
Time limit2sMemory limit512 MB
Count the corners of the region inside the square town where the Fenster house is closest.
Problem
Fludtown is a square township in Rainee county, one kilometer on each side. The houses are scattered around the township at random, but ownership follows one simple rule: the land at any point in Fludtown belongs to the house whose straight-line distance to that point is shortest. No two houses stand on the same spot.
Last week the Fenster family moved into one of the houses. Mr. Fenster had the property agent drive markers into the edges of his land so that he could build a fence around the house. Yesterday a heavy rainstorm hit Fludtown and washed every marker away. He does still have the town map, which shows where the Fenster house and the other properties are.
Mr. Fenster is going to buy fencing material from the depot outside town. Work out how many fenceposts he needs to buy. A fencepost goes only where the fence changes direction. If his property reaches the border of Fludtown, count the posts needed along the border as well. Some houses have no effect at all on the number of fenceposts.
Input
The location of a Fludtown house is given by its coordinates. The origin of the coordinate system sits at the south-west corner of Fludtown, the axis runs from west to east, the axis runs from south to north, and one coordinate unit is one meter.
Let () be the number of houses in Fludtown. The input has lines. The first line contains the integer . Each of the next lines contains two integers and separated by a space, the coordinates of one house. The Fenster family house comes before the rest, that is, on the second line. Every house lies inside the square township of area 1 km² or on its edge, so and .
Output
Print one integer, the number of fenceposts required to build the fence around the Fenster property.
Hint
- The perpendicular bisector of the segment joining and is the line
- If the lines and meet, they meet at