atcoder#ABC226D. [ABC226D] Teleportation
[ABC226D] Teleportation
Score : points
Problem Statement
The Republic of AtCoder lies on a Cartesian coordinate plane. It has towns, numbered . Town is at , and no two different towns are at the same coordinates.
There are teleportation spells in the nation. A spell is identified by a pair of integers , and casting a spell at coordinates teleports you to .
Snuke is a great magician who can learn the spell for any pair of integers of his choice. The number of spells he can learn is also unlimited. To be able to travel between the towns using spells, he has decided to learn some number of spells so that it is possible to do the following for every pair of different towns .
- Choose just one spell among the spells learned. Then, repeatedly use just the chosen spell to get from Town to Town .
At least how many spells does Snuke need to learn to achieve the objective above?
Constraints
- if .
Input
Input is given from Standard Input in the following format:
Output
Print the minimum number of spells Snuke needs to learn.
3
1 2
3 6
7 4
6
The figure below illustrates the positions of the towns (along with the coordinates of the four corners).
If Snuke learns the six spells below, he can get from Town to Town by using one of the spells once for every pair , achieving his objective.
Another option is to learn the six spells below. In this case, he can get from Town to Town by using one of the spells twice for every pair , achieving his objective.
There is no combination of spells that consists of less than six spells and achieve the objective, so we should print .
3
1 2
2 2
4 2
2
The optimal choice is to learn the two spells below:
4
0 0
0 1000000000
1000000000 0
1000000000 1000000000
8