#abc257d. D - Jumping Takahashi 2
D - Jumping Takahashi 2
Score : points
问题描述
在Takahashi居住的二维平面城镇中,有个蹦床。第个蹦床位于点处,具有力量值。Takahashi的跳跃能力用表示,初始时。每次Takahashi训练时,会增加1。
Takahashi可以从第个蹦床跳到第个蹦床,当且仅当:
- 。
Takahashi的目标是能够选择一个起始蹦床,以便从这个蹦床出发,通过一些跳跃到达任何蹦床。
他至少需要训练多少次才能实现目标?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are trampolines on a two-dimensional planar town where Takahashi lives. The -th trampoline is located at the point and has a power of . Takahashi's jumping ability is denoted by . Initially, . Every time Takahashi trains, increases by .
Takahashi can jump from the -th to the -th trampoline if and only if:
- .
Takahashi's objective is to become able to choose a starting trampoline such that he can reach any trampoline from the chosen one with some jumps.
At least how many times does he need to train to achieve his objective?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
-10 0 1
0 0 5
10 0 1
11 0 1
Sample Output 1
2
If he trains twice, , in which case he can reach any trampoline from the -nd one.
For example, he can reach the -th trampoline as follows.
-
Jump from the -nd to the -rd trampoline. (Since and , it holds that .)
-
Jump from the -rd to the -th trampoline. (Since and , it holds that .)
Sample Input 2
7
20 31 1
13 4 3
-10 -15 2
34 26 5
-2 39 4
0 -50 1
5 -20 2
Sample Output 2
18
update @ 2024/3/10 10:55:27