A1096 | [COCI-2006_2007-olympiad]#3 SABOR
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
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.
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.
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.
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 100
0.
No two obstacles will be in the same cell and there will be no obstacle in cell (0, 0).
Each of the following B lines contains two integers, the coordinates of one obstacle. The absolute value of both coordinates will be less than 100
0.
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.
输入输出样例
输入 #1
0 2
输出 #1
9 4
输入 #2
4 5 -1 1 0 -1 0 1 1 0
输出 #2
10 16
输入 #3
4 50000 1 1 -1 -1 1 -1 -1 1
输出 #3
2500099997 2500000000
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted