当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2903:Joy of Mobile Routing

题目描述
A computer professor, who is fond of programming, has come to Tehran to pay a visit to our regional contest. After hearing about such an event, he has tried his best to be able to participate in the contest as a visitor. He would decide to hold such contests in his university, if he finds it fun enough.
As could be predicted, he has been lost in our large and crowded city, Tehran. He does not know where to go. Getting really tired, he is standing in a city intersection when he suddenly remembers the phone number of a friend in the organizing committee, and instantly calls him. The friend understands the situation and wants to route the professor through mobile phone calls. He plans to give the professor directions at each intersection; i.e. he tells the tired professor in which direction to move, and after reaching the next intersection, there is another phone call, to get the new direction, etc. This process continues, until the professor sees his friend at the destination intersection, waiting for him. Due to poor telecommunications installment, not all city intersections are accessible through mobile network.
The professor should get to the regional contest location as soon as possible. There are a number of antennas located in some of city intersections. A city intersection is accessible through the network if an antenna can see the point; i.e. there is an imaginary straight line connecting the intersection to any part of the antenna. The line can never cross a building, but touching a boundary does not block the mobile connection. The city is composed of R*C rectangular blocks. Each block is a building having 10 meters width and length.
You should write a program to find out the shortest possible mobile route; i.e. a route that lets the professor call his friend from each intersection, until reaching the destination. The program is given R, C and height of each building and each antenna, and the location of antennas.
输入解释
The only number of the first line, T, (1 <= T <= 20) is the number of different test cases to be solved. T input blocks follow, which describe different independent test cases.
The first line of a block, contains two integers R, C (1 <= R,C <= 50), the number of rows and columns of the city map, respectively. Next R lines, each contains C non-negative integers, 0 <= Hij <= 1000, describing the building heights. The first entry is the leftmost building in the uppermost row. The coordinates of the starting and ending points are given next; the row coordinates come first in each line.
The lower and rightmost intersection is (R,C), while the opposite intersection is (0, 0).
Followed is A, (0 <= A <= 100), the number of mobile antennas. Next A lines describe the antennas by three numbers, r, c, (0 <= r <= R, 0 <= c <= C), and h, (0 <= h <= 1000). It means that there is an antenna with height h at the intersection (r, c).
输出解释
For each block of the input, write a single integer, which is the least distance the professor is to travel before getting to the contest, in meters. If there is no mobile route, and the professor’s friend is to choose another way for the routing, output -1 instead.
输入样例
1
3 2
0 10
20 15
5 4
3 0
1 2
1
0 0 6
输出样例
40

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Tehran 2005

源链接: POJ-2903

最后修改于 2020-10-29T06:47:13+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536