POJ 2907 Collecting Beepers DFS+回溯+剪枝
来源:互联网 发布:最小linux系统 编辑:程序博客网 时间:2024/05/16 16:04
http://poj.org/problem?id=2907
Description
Karel is a robot who lives in a rectangular coordinate system where each place is designated by a set of integer coordinates (x and y). Your job is to design a program that will help Karel pick up a number of beepers that are placed in her world. To do so you must direct Karel to the position where each beeper is located. Your job is to write a computer program that finds the length of the shortest path that will get Karel from her starting position, to each of the beepers, and return back again to the starting position.
Karel can only move along the x and y axis, never diagonally. Moving from one position (i, j) to an adjacent position (i, j + 1), (i, j − 1), (i − 1, j), or (i + 1, j) has a cost of one.
You can assume that Karel’s world is never larger than 20 × 20 squares and that there will never be more than 10 beepers to pick up. Each coordinate will be given as a pair (x, y) where each value will be in the range 1 through the size of that particular direction of the coordinate system.
Input
First there will be a line containing the number of scenarios you are asked to help Karel in. For each scenario there will first be a line containing the size of the world. This will be given as two integers (x-size and y-size). Next there will be one line containing two numbers giving the starting position of Karel. On the next line there will be one number giving the number of beepers. For each beeper there will be a line containing two numbers giving the coordinates of each beeper.
Output
The output will be one line per scenario, giving the minimum distance that Karel has to move to get from her starting position to each of the beepers and back again to the starting position.
Sample Input
110 101 142 35 59 46 5
Sample Output
The shortest path has length 24
- POJ 2907 Collecting Beepers DFS+回溯+剪枝
- POJ 2907 Collecting Beepers (DFS+回溯)
- poj 2907 Collecting Beepers dfs
- POJ 2907 Collecting Beepers
- POJ-2907(全排列->dfs)(Collecting Beepers)
- POJ 2907 Collecting Beepers 笔记
- POJ Collecting Beepers (dfs 深度搜索)
- poj 2907 Collecting Beepers 邮递员问题暴力解法
- Poj 2907 Collecting Beepers【枚举+最短路径】
- Collecting Beepers(简单的dfs)
- POJ 1011 Sticks(DFS回溯剪枝)
- POJ 2531 dfs回溯(小剪枝)
- POJ 2676 Sudoku (DFS回溯剪枝)
- UVa 10496 - Collecting Beepers
- dfs + 回溯 +剪枝
- Curling 2.0 DFS+回溯+剪枝
- hdu 5113(dfs+剪枝+回溯)
- poj 2192 DFS+剪枝
- java调用php的webservice示例
- sql_split函数
- Java 根据路径生成文件夹
- 每天坚持1-2小时就行,谁也不是傻子.肯定能会
- 3d max 计划
- POJ 2907 Collecting Beepers DFS+回溯+剪枝
- 输入一组string.判断哪个单词输入的连续次数最多
- 《基于可逆整数时间域重叠变换的分类矢量量化编码》实验结果图
- 5开发软件配置 --JDK环境变量的设置与export指令的关系
- 最大值最小化
- 开发者谈优秀应用的7个必备要素
- 没有眼泪的感动
- awk编写hadoop streaming 总结
- 新手学习中