#P4335. [COI2007] Sabor
[COI2007] Sabor
题目描述
The president of the political party in power is holding a conference in 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 in cell (0, 0). This is also where the president of the party lives.
执政党的总书记正在人民大会堂举行会议。党员们都在一个二维平面的网格中,一个党员在一个格子中(除了含有障碍的格子)。会堂位于(0,0),是总书记的位置。
Politicians make steps in one of the four directions (up, down, left, right), moving to one of the four adjacent cells in one step. They can't enter cells with obstacles. The conference will be attended by all party members that can reach headquarters in S steps or less. Each member coming to the conference will take the shortest route to 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 on the political scene). Write a program that determines how many politicians come to the conference as members of the party in power, and how many come as members of the opposing party.
总书记发现,代表们每走一步,就会改变他们的党派关系,成为另一个政党的成员(国家实行两党制)。编写一个程序来计算有多少代表是执政党,多少代表是反对党。
输入格式
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 two integers on a single line separated by a space, the number of politicians that come to the conference as members of the party in power and the opposing party, respectively.
0 2
9 4
4 5
-1 1
0 -1
0 1
1 0
10 16
4 50000
1 1
-1 -1
1 -1
-1 1
2500099997 2500000000
提示
Croatian Olympiad in Informatics 2007 Task 3