D. 遥远的她

    Type: Default File IO: distance 1000ms 256MiB

遥远的她

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题面描述

在一个坐标平面上,有 NN 个点 P1,P2,,PNP_1, P_2, \ldots, P_N,其中点 PiP_i 的坐标为 (Xi,Yi)(X_i, Y_i)。两点 AABB 之间的距离 dist(A,B)\text{dist}(A, B) 定义如下:

遥远的她最初位于点 AA。遥远的她在位置 (x,y)(x, y) 可以跳到 (x+1,y+1)(x+1, y+1), (x+1,y1)(x+1, y-1), (x1,y+1)(x-1, y+1)(x1,y1)(x-1, y-1) 中的一个点,完成一次跳跃。

dist(A,B)\text{dist}(A, B) 定义为从点 AA 到点 BB 需要的最小跳跃次数。如果在任意次数的跳跃后无法从点 AA 到达点 BB,则令 dist(A,B)=0\text{dist}(A, B) = 0

计算以下和:

$$\sum_{i=1}^{N-1} \sum_{j=i+1}^{N} \text{dist}(P_i, P_j) $$

输入格式

一行一个整数 NN ,代表点的数量。

接下来 NN 行,每行两个整数 (Xi,Yi)(X_i, Y_i)

输出格式

一行一个整数,表示答案

3
0 0
1 3
5 6
3
5
0 5
1 7
2 9
3 8
4 6
11

数据范围与约定

  • 对于 30%30\% 的数据,满足 N100N \leq 100
  • 对于 100%100\% 的数据,满足 $2 \leq N \leq 2 \times 10^5, 0 \leq X_i, Y_i \leq 10^8$ 保证没有相同的 (Xi,Yi)(X_i, Y_i)

0814A班测试

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2025-8-14 8:30
End at
2025-8-14 11:42
Duration
3.2 hour(s)
Host
Partic.
41