22099_DrivethroughMegaCity

2022-5-16 18:21| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89506109459400-Problem List-采集的数据-后羿采集器.html

Pro.ID

22099

Title

Drive through MegaCity

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22099

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    MegaCity of the future is a rectangular grid of streets. Each intersection has integer Cartesian coordinates x and y. To get from intersection a with coordinates xa, ya to intersection b with coordinates xb, yb you need to drive exactly |xa-xb|+|ya-yb| blocks. Usually, it takes 10 time units to drive one block, so one can easily compute the time it takes to get from a to b. However, traffic jams that occur in MegaCity turn estimation of minimal driving time into a complex problem that you have to solve.

    Traffic jams in MegaCity aff ect a rectangular area that is specified by coordinates of its bottom-left and top-right corners. The time to travel one block in the traffic jam is specified. All streets that are strictly inside the rectangular region are a ffected by the traffic jam. Sometimes, it is better to drive around the traffic jams to save time, but sometimes it is better to drive through some trac jams as shown in the example ---- 17 blocks are driven outside of traffic jams, taking 10 time units per block, and 2 blocks in the light traffic jam with 11 time units per block.

    输入

    The first line of the input file contains four integer numbers xa, ya, xb, and yb ---- coordinates of the start and finish intersections. The second line of the input file contains a single integer number n (0 ≤ n ≤ 1000) which specifies the number of traffic jams. The following n lines describe traffic jams. Each traffic jam is described by five integer numbers x1,i , y1,i , x2,i , y2,i and ti, where first four numbers are coordinates of the bottom-left and top-right corners of the jammed area (x1,i < x2,i , y1,i < y2,i ), and ti (10 < ti ≤ 108) is the time it takes to travel one block inside this traffic jam. All coordinates in the input file are from 0 to 108 inclusive. Areas of traffic jams neither intersect nor touch each other. Start and finish points are different and do not lie inside nor on the border of any traffic jam.

    输出

    Description

    MegaCity of the future is a rectangular grid of streets. Each intersection has integer Cartesian coordinates x and y. To get from intersection a with coordinates xa, ya to intersection b with coordinates xb, yb you need to drive exactly |xa-xb|+|ya-yb| blocks. Usually, it takes 10 time units to drive one block, so one can easily compute the time it takes to get from a to b. However, traffic jams that occur in MegaCity turn estimation of minimal driving time into a complex problem that you have to solve.

    Traffic jams in MegaCity aff ect a rectangular area that is specified by coordinates of its bottom-left and top-right corners. The time to travel one block in the traffic jam is specified. All streets that are strictly inside the rectangular region are a ffected by the traffic jam. Sometimes, it is better to drive around the traffic jams to save time, but sometimes it is better to drive through some trac jams as shown in the example ---- 17 blocks are driven outside of traffic jams, taking 10 time units per block, and 2 blocks in the light traffic jam with 11 time units per block.

    Input

    The first line of the input file contains four integer numbers xa, ya, xb, and yb ---- coordinates of the start and finish intersections. The second line of the input file contains a single integer number n (0 ≤ n ≤ 1000) which specifies the number of traffic jams. The following n lines describe traffic jams. Each traffic jam is described by five integer numbers x1,i , y1,i , x2,i , y2,i and ti, where first four numbers are coordinates of the bottom-left and top-right corners of the jammed area (x1,i < x2,i , y1,i < y2,i ), and ti (10 < ti ≤ 108) is the time it takes to travel one block inside this traffic jam. All coordinates in the input file are from 0 to 108 inclusive. Areas of traffic jams neither intersect nor touch each other. Start and finish points are different and do not lie inside nor on the border of any traffic jam.

    Output

    Write to the output file a single integer --- the minimal driving time from intersection a to intersection b.

    Sample Input

    1 6 15 3
    4
    2 1 3 7 44
    5 2 10 4 33
    8 5 11 9 22
    12 1 14 8 11

    Sample Output

    192

    Source

    样例输入

    1 6 15 3
    4
    2 1 3 7 44
    5 2 10 4 33
    8 5 11 9 22
    12 1 14 8 11

    样例输出

    192

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部