Hdu 2722 here We Go (relians) Again (input handling nausea)

Source: Internet
Author: User
Tags integer time limit

Link:

http://acm.hdu.edu.cn/showproblem.php?pid=2722

Topic:

Here We Go (relians) Again

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 360 accepted Submission (s): 204

Problem Description

The Gorelians are a warlike race that travel the universe conquering new worlds as a form of recreation. Given their violent, fun-loving nature, keeping their leaders alive are of serious concern. Part of the Gorelian security plan involves changing the traffic patterns of their in a daily basis, and cities Al L Gorelian Government officials to the government building by the fastest possible.

Fortunately for the Gorelian Minister of Traffic (that would is you), all Gorelian cities The are out as a laid gr ID of blocks, where each of the blocks is a square measuring 2520 rels/side (a rel is the Gorelian official unit of Distance). The speed limit between two adjacent intersections is always constant, and may range from 1 to 9 rels per blip (a blip, O F course, being the Gorelian official unit of time). Since Gorelians have outlawed decimal numbers as unholy (hey, if you are re the dominant force in the known universe, can Outlaw whatever you want), speed limits are integer values. This explains why Gorelian blocks are precisely 2520 rels into length:2520 is the least common multiple of the integers 1 t Hrough 9. Thus, the time required to travel between two adjacent are intersections an integer number of always.

In all Gorelian cities, government housing are always at the northwest corner of the "city" while the government I s always at the southeast corner. Streets between intersections might is one-way or two-way, or possibly even for closed (all this repair with tinkering Ffic patterns causes a lot of accidents). Your job, given the details of speed limits, street directions, and street closures for a Gorelian city, are to determine t He fastest route from government housing to the government building. (It is possible, due to street directions and closures, which no route exists, in which case a Gorelian official Holiday is declared, and the Gorelian officials take the "day".)


The picture above shows a Gorelian city marked with speed limits, one way streets, and one closed street. It is assumed this streets are always traveled at the exact posted, speed limit, and this turning a corner takes zero time. Under These conditions, you should being able to determine this fastest route from government to the housing Building in the is 1715 blips. And if the next day, the ' only change ' is ' that ' closed road is opened to two way traffic in 9 rels per blip, the fastest Route becomes 1295 blips. On the other hand, suppose the three one-way streets are switched-southbound to northbound (with the closed road Ining closed). In this case, no route would is possible and the day would to be declared a holiday.

Input

The input consists of a set of cities for which your must find a fastest route if one exists. The ' a ' of the input case contains two integers, which are the vertical and horizontal number of city blocks, Respec Tively. The smallest city are a single, or 1 by 1, and the largest are blocks. The remainder of the input specifies speed limits and traffic directions for streets between intersections, one row of str EET segments at a time. The "the" of the input (after the dimensions line) contains the "data for" the northernmost east-west street segments. The next line contains the "data for" the northernmost row of North-south street segments. Then the next row of East-west streets, Then north-south streets, and so on, until the southernmost row of East-west Stree Ts. Speed limits and directions of travel are specified in, and each consists of of a, integer from 0 to 9 indicating speed limit, and a symbol indicating which direction traffic may flow. A Zero speed limit means the road is closed. All digits and symbols are delimited by a. For East-west streets, the symbol would be a asterisk ' * ' which indicates travel are allowed in both directions, a Less-tha N symbol ' < ' which indicates travel is allowed only in a east-to-west direction, or a Greater-than symbol ' > ' which Indicates travel is allowed a west-to-east direction. For North-south streets, a asterisk again indicates travel are allowed in either direction, a lowercase "vee" character ' V ' Indicates travel is allowed-in-a north-to-south directions, and a caret symbol ' ^ ' indicates travel is allowed-only In a south-to-north direction. A zero speed, indicating a closed road, is always followed by a asterisk. Input cities continue in this manner until a value of the ' zero is ' specified for both to the vertical and horizontal.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.