SOJ 1321. Robot
2013-08-24 21:43
309 查看
1321. Robot
Constraints
Time Limit: 1 secs, Memory Limit: 32 MBDescription
Karell Incorporated has designed a new exploration robot that has the ability to explore new terrains, this new robot can move in all kinds of terrain, it only needs more fuel to move in rough terrains, and less fuel in plain terrains. The only problem thisrobot has is that it can only move orthogonally, the robot can only move to the grids that are at the North, East, South or West of its position.The Karell`s robot can communicate to a satellite dish to have a picture of the terrain that is going to explore, so it can select the best route to the ending point, The robot always choose the path that needs the minimum fuel to complete its exploration,however the scientist that are experimenting with the robot, need a program that computes the path that would need the minimum amount of fuel. The maximum amount of fuel that the robot can handle is 9999 unitsThe Terrain that the robot receives from the satellite is divided into a grid, where each cell of the grid is assigned to the amount of fuel the robot would need to pass thought that cell. The robot also receives the starting and ending coordinates of the explorationarea.Path ExampleFrom (1,1) to (5,5)Fuel needed 10Input
The first line of the input file is the number of tests that must be examined.The first line of the test is the number of rows and columns that the grid will contain. The rows and columns will be 0 < row100 , 0< column100The next lines are the data of the terrain gridThe last line of the test has the starting and ending coordinates.Output
One line, for each test will have the amount of fuel needed by the robotSample Input
3 5 5 1 1 5 3 2 4 1 4 2 6 3 1 1 3 3 5 2 3 1 2 2 1 1 1 1 1 1 5 5 5 4 2 2 15 1 5 1 15 1 5 3 10 1 5 2 1 1 8 13 2 15 1 1 1 4 10 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 10
Sample Output
10 15 19
相关文章推荐
- N!的从最末一个非0位开始自低位向高位数的第M位 soj 1115
- soj 3102 不明白
- soj 2932:道路
- SOJ 4139 APPLE 树状DP
- SOJ 2035: The Tiling Problem
- soj 1305. Who’s Winner?
- soj 1621. Circles in Circle
- soj - 1014 - Specialized Four-Dig
- soj 1939. 煎饼堆
- 1001. Black Magic (soj)
- Sicily 1142 排序 (SOJ 1142) 【搜索剪枝】
- soj1090.Highways
- soj dsa extra 1002 sudoku
- soj 1698 Hungry Cow_三角函数
- 【异或】SOJ Find Differences
- soj题目分类
- SOJ. Locker puzzle
- SOJ 13984
- SOJ.Cannonball Pyramids
- soj 3360 Buying hay (完全背包)