#abc351e. E - Jump Distance Sum
E - Jump Distance Sum
Score: points
问题陈述
在坐标平面上,有 个点 ,其中点 的坐标为 。 两个点 和 之间的距离 定义如下:
一只兔子最初在点 。 位于位置 的兔子可以在一次跳跃中跳到 ,, 或 。 定义为从点 跳到点 所需的最少跳跃次数。 如果在任意次跳跃后都不可能从点 跳到点 ,则让 。
计算总和 $\displaystyle\sum_{i=1}^{N-1}\displaystyle\sum_{j=i+1}^N \text{dist}(P_i, P_j)$。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
On a coordinate plane, there are points , where point has coordinates .
The distance between two points and is defined as follows:
A rabbit is initially at point .
A rabbit at position can jump to , , , or in one jump.
is defined as the minimum number of jumps required to get from point to point .
If it is impossible to get from point to point after any number of jumps, let .
Calculate the sum $\displaystyle\sum_{i=1}^{N-1}\displaystyle\sum_{j=i+1}^N \text{dist}(P_i, P_j)$.
Constraints
- For ,
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the value of $\displaystyle\sum_{i=1}^{N-1}\displaystyle\sum_{j=i+1}^N \text{dist}(P_i, P_j)$ as an integer.
Sample Input 1
3
0 0
1 3
5 6
Sample Output 1
3
, , and have coordinates , , and , respectively.
The rabbit can get from to in three jumps via , but not in two or fewer jumps,
so .
The rabbit cannot get from to or from to , so .
Therefore, the answer is $\displaystyle\sum_{i=1}^{2}\displaystyle\sum_{j=i+1}^3\text{dist}(P_i, P_j)=\text{dist}(P_1, P_2)+\text{dist}(P_1, P_3)+\text{dist}(P_2, P_3)=3+0+0=3$.
Sample Input 2
5
0 5
1 7
2 9
3 8
4 6
Sample Output 2
11