#P14010. 「florr IO Round 1」遍历游戏

「florr IO Round 1」遍历游戏

Description

There are nn key points on the plane, each with integer coordinates in [1,105][1,10^5].

It is guaranteed that these key points are four-connected, and that the plane becomes eight-connected after removing these key points.

Let dis(i,j)dis(i,j) denote the shortest path length from the ii-th key point to the jj-th key point, where a valid path is defined as follows:

A path is a sequence of point pairs (x1,y1),(x2,y2),,(xk,yk)(x_1,y_1),(x_2,y_2),\dots,(x_k,y_k), where the Manhattan distance between each pair of adjacent points is 11, that is, i[1,n),xixi+1+yiyi+1=1\forall i\in[1,n), |x_i-x_{i+1}|+|y_i-y_{i+1}|=1, and every point in the sequence is a key point.

The length of this path is defined as k1k-1, and the shortest path between two points is the shortest among all valid paths.

Given nn and kk, find how many pairs (i,j)(i,j) satisfy dis(i,j)=kdis(i,j)=k.

Input Format

The first line contains two integers, nn and kk, representing the number of key points and the parameter kk.

The next nn lines each contain two integers, where the ii-th line gives the coordinates (xi,yi)(x_i, y_i) of the ii-th key point.

It is guaranteed that the given points are distinct and satisfy the properties described above.

Output Format

Output a single integer representing the answer.

5 2
1 3
1 4
2 4
2 5
2 6
3

Hint

Data Range

This problem uses bundled tests.

Subtask nn\le kk\le Special Property Score
11 10310^3 None 1515
22 10510^5 1010
33 10510^5 All key points form a rectangle 2020
44 No 2×22\times 2 square is fully occupied by key points
55 None 3030
  • For 100%100\% of the data, it is guaranteed that 1n,k,xi,yi1051\le n,k,x_i,y_i\le 10^5.

Translated by ChatGPT 4.1