#abc226d. D - Teleportation
D - Teleportation
Score : points
问题陈述
在AtCoder共和国中,国家位于笛卡尔坐标平面上。
它拥有个城镇,分别编号为。第个城镇位于坐标处,并且没有两个不同的城镇位于相同的坐标。
该国有着传送法术。一个法术由一对整数标识,在坐标处施放法术会将你传送到坐标的位置。
Snuke是一位伟大的魔法师,他可以选择学习任意整数对的法术。他可以学习的法术数量也是无限的。
为了能够使用法术在各个城镇之间旅行,他决定学习一些法术,使得对于每一对不同的城镇,都能够做到以下操作:
- 仅从已学习的法术中选择一个法术,然后仅重复使用所选的法术从城镇到达城镇。
至少需要学习多少个法术,Snuke才能实现上述目标?
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
3
1 2
3 6
7 4
Sample Output 1
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 .
Sample Input 2
3
1 2
2 2
4 2
Sample Output 2
2
The optimal choice is to learn the two spells below:
Sample Input 3
4
0 0
0 1000000000
1000000000 0
1000000000 1000000000
Sample Output 3
8
update @ 2024/3/10 09:55:25