P28351 [洛谷] [COI2007] Sabor
提高+
题目描述

Problem Description

The president of the ruling party is holding a conference at the party headquarters. Politicians, members of the party, live in a two-dimensional grid, one member in each cell (except in cells containing obstacles). The headquarters are located at cell (0, 0), which is also where the president of the party resides.

Politicians move in one of the four directions (up, down, left, right), moving to one of the four adjacent cells in one step. They cannot enter cells with obstacles. The conference will be attended by all party members who can reach the headquarters in S steps or less. Each member coming to the conference will take the shortest route to the headquarters (or any such route if there is more than one).

The president has observed that politicians change their party affiliation with each step they take, becoming a member of the other party (there are only two parties in the political scene). Write a program that determines how many politicians come to the conference as members of the ruling party and how many come as members of the opposing party.

Input Format

The first line contains two integers B and S (0 ≤ B ≤ 10,000, 1 ≤ S ≤ 10,000,000), the number of obstacles and the largest number of steps from the task description.

Each of the following B lines contains two integers, the coordinates of one obstacle. The absolute value of both coordinates will be less than 1000.

No two obstacles will be in the same cell, and there will be no obstacle in cell (0, 0).

Output Format

Output two integers on a single line separated by a space, the number of politicians that come to the conference as members of the ruling party and the opposing party, respectively.

Sample Input and Output

Sample Input #1

0 2

Sample Output #1

9 4

Sample Input #2

4 5
-1 1
0 -1
0 1
1 0

Sample Output #2

10 16

Sample Input #3

4 50000
1 1
-1 -1
1 -1
-1 1

Sample Output #3

2500099997 2500000000

Notes

Croatian Olympiad in Informatics 2007
Task 3

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
0 2
样例输出
9 4