POJ 3626 Mud Puddles 练习 BFS 宽度优先搜索
来源:互联网 发布:淘宝买电动车怎么样? 编辑:程序博客网 时间:2024/05/22 07:43
http://poj.org/problem?id=3626
Description
Farmer John is leaving his house promptly at 6 AM for his daily milking of Bessie. However, the previous evening saw a heavy rain, and the fields are quite muddy. FJ starts at the point (0, 0) in the coordinate plane and heads toward Bessie who is located at (X, Y) (-500 ≤ X ≤ 500; -500 ≤ Y ≤ 500). He can see all N (1 ≤ N ≤ 10,000) puddles of mud, located at points (Ai, Bi) (-500 ≤ Ai ≤ 500; -500 ≤ Bi ≤ 500) on the field. Each puddle occupies only the point it is on.
Having just bought new boots, Farmer John absolutely does not want to dirty them by stepping in a puddle, but he also wants to get to Bessie as quickly as possible. He's already late because he had to count all the puddles. If Farmer John can only travel parallel to the axes and turn at points with integer coordinates, what is the shortest distance he must travel to reach Bessie and keep his boots clean? There will always be a path without mud that Farmer John can take to reach Bessie.
Input
* Line 1: Three space-separate integers: X, Y, and N.
* Lines 2..N+1: Line i+1 contains two space-separated integers: Ai and Bi
Output
* Line 1: The minimum distance that Farmer John has to travel to reach Bessie without stepping in mud.
Sample Input
1 2 70 2-1 33 11 14 2-1 12 2
Sample Output
11
- POJ 3626 Mud Puddles 练习 BFS 宽度优先搜索
- POJ 3626 Mud Puddles (BFS)
- poj 3626 Mud Puddles (简单BFS)
- POJ 3626 Mud Puddles(bfs)
- POJ 3626 Mud Puddles(BFS)【模板】
- POJ 3626 Mud Puddles
- POJ 3626 Mud Puddles(超简单BFS)
- poj 3278(bfs宽度优先搜索)
- 宽度优先搜索 BFS
- 宽度优先搜索BFS
- 宽度优先搜索bfs
- Prime Path - POJ 3126 BFS宽度(广度)优先搜索
- BFS宽度优先搜索思想
- 广度/宽度优先搜索(BFS)
- 广度/宽度优先搜索(BFS)
- BFS宽度优先搜索算法
- BFS宽度优先搜索思想
- 广度/宽度优先搜索(BFS)
- kmap_atomic的细节以及改进
- 爸爸,我给你报喜
- Eclipse3.6与m2eclipse,run-jetty-run插件对WEB项目进行热部署以及在jar源码中进行调试(二)
- TCP/IP协议头部结构体
- 语音聊天
- POJ 3626 Mud Puddles 练习 BFS 宽度优先搜索
- Synchronized机制
- 读取Properties文件的一般做法
- How does XNA framework 4.0 cross platforms
- MFC单文档 关闭按钮屏蔽 最小化到托盘
- Git: push 出错的解决 (branch is currently checked out)
- 也来谈谈"完美"跨域
- 新I/O
- 麒麟远创面试题3:二叉树中求两个节点的最低公共祖先节点