#P3289. Vegetable Garden Wells
Vegetable Garden Wells
Vegetable Garden Wells
Uncle Fang wants to cultivate the most traditional and pure vegetables by building his own vegetable garden. He has planned n distinct planting locations on an empty plot. To ensure that the vegetables are irrigated with the sweetest well water, he will build two wells, well A and well B. However, the location of each well is determined by a unique rule:
- Each well is built exactly at the center of the vegetables it irrigates. That is, if well A irrigates a set S of vegetables with coordinates \((x_i,y_i)\), then its coordinates are \(\left(\frac{\sum_{(x,y)\in S} x}{|S|},\frac{\sum_{(x,y)\in S} y}{|S|}\right)\). Similarly for well B with the set T.
- Every vegetable must be irrigated by one of these wells.
- Each well must irrigate at least one vegetable.
- A vegetable which is strictly closer to well A than well B must be irrigated by A; one strictly closer to well B must be irrigated by B. In case a vegetable is equidistant to the two wells, it may be irrigated by either.
- The two wells must be located at different positions.
Two irrigation schemes are considered different if the set of vegetables irrigated by well A is different. Given the coordinates of the n vegetable planting locations, count the number of valid irrigation schemes following the above rules.
Note: When comparing distances, use the Euclidean distance. All comparisons of distances are allowed to be equality (i.e. vegetables equidistant from the two well centers may be assigned arbitrarily to either well).
The formula for a center is given in \(\LaTeX\) as follows:
[ A = \left(\frac{\sum_{i \in S} x_i}{|S|}, \frac{\sum_{i \in S} y_i}{|S|}\right)\quad,\quad B = \left(\frac{\sum_{j \in T} x_j}{|T|}, \frac{\sum_{j \in T} y_j}{|T|}\right). ]
inputFormat
The first line contains an integer n indicating the number of vegetables. Each of the following n lines contains two integers x and y, representing the coordinates of a vegetable. It is guaranteed that all points are distinct.
outputFormat
Output a single integer, representing the number of valid irrigation schemes.
sample
2
0 0
1 0
2