toj 2696 Collecting Beepers
2009-05-20 19:22
405 查看
2696. Collecting Beepers
Time Limit: 1.0 Seconds Memory Limit: 65536K
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 thatwill 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.
Source: Nordic Collegiate Contest 2002
Problem ID in problemset: 2696
Submit Back Runs Statistics Clarifications
Time Limit: 1.0 Seconds Memory Limit: 65536K
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 thatwill 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 specifications
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 specifications
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
1 10 10 1 1 4 2 3 5 5 9 4 6 5
Output for sample input
The shortest path has length 24
Source: Nordic Collegiate Contest 2002
Problem ID in problemset: 2696
Submit Back Runs Statistics Clarifications
相关文章推荐
- TOJ_1001解题报告
- TOJ 2199 A+B Problem的无奈 2006-07-21
- toj 2815 Searching Problem
- toj 1705 Scavenger Hunt
- toj 2972 MOVING DHAKA
- TOJ 1132 Knight Moves BFS求最短路径
- toj 3474 解题报告
- 【TOJ】1416. Catenyms --欧拉路
- TOJ 2189. The Key Stations 【求无向图的割点】
- [TOJ] 3243 Blocked Road -- 树状数组、线段树
- TOJ 3817 Matchsticks
- TOJ 1959 POJ 1562 Oil Deposits BFS DFS入门题 C语言
- SOJ 2745 树状数组 TOJ 3505 树状数组
- TOJ-3072 Train Order
- TOJ 1547
- TOJ 3843 快速排序 折半查找
- poj2696(mod 数学上的定义)
- TOJ 1037 POJ 2771 LA 3415 Guardian of Decency / 二分图
- TOJ 3185 二叉树的遍历
- TOJ1235最大连续子序列