Problem J: | Fastest Vs Cheapest |
Time Limit: 10 seconds Memory Limit: 32 MB |
Traffic jam is one of the major concerns of Dhaka city. Lately this has been realized through some desperate measures taken by the government. While the actions taken reduce traffic jams, they do create some unwanted problems as well. Take for example the latest ban on non-motorize vehicles on an important road of Dhaka. It certainly has reduced jams in that region, but people are having trouble to get a reasonable means for transportation.
After analyzing the present situation we came to know that some people would like to find the fastest way with the cheapest cost, and some would like to find the cheapest route with the fastest time. They may sound similar -- for some certain route they are the same too. But this is not always true.
We'd like to hire you to solve the problem for both the group so that they can learn to do some trade-off. You have been told to solve the problem in a smaller scale at first. You're provided with the following information:
Name | Type | Average Speed | Minimum Fare | Fare for further travel | Availability (wait for) |
---|---|---|---|---|---|
Rickshaw | Non-motorized | 10 kmph | 5 Tk for first 1 km | 2 Tk per km | 2 min |
Auto-Rickshaw | Motorized | 30 kmph | 20 Tk for first 2 km | 10 Tk per km | 3 min |
Taxi-Cab | Motorized | 50 kmph | 20 Tk for first 2 km | 16 Tk per km | 10 min |
Bus | Motorized | 40 kmph | 2 Tk for first 5 km | 1 Tk per km | 30 min |
U V DISTANCE TYPEU, V are integers < N. DISTANCE is an integer < 21, the unit is kilo-meters. TYPE can be: N for Non-motorized, M for Motorized, and A for all types of vehicle.
5 10 0 1 0 1 10 N 0 2 11 A 0 3 14 M 0 4 2 M 1 2 1 N 1 3 6 N 1 4 13 N 2 3 7 M 2 4 19 N 3 4 12 A 2 4 1 0 0 1 10 N 0 1 11 M 0 1 12 A 0 1 13 N 3 4 1 2 0 1 10 N 0 1 11 M 0 1 12 A 0 1 13 N 3 3 0 2 0 1 10 N 1 2 2 M 1 2 1 N 3 2 0 2 0 1 10 N 1 2 1 M
Case#1 169 31.20 13 54.50 Case#2 164 23.20 8 46.50 Case#3 UNREACHABLE UNREACHABLE Case#4 25 68.00 25 68.00 Case#5 43 67.00 25 93.50
Problem setter: Monirul Hasan (Tomal), CSE Dept, Southeast University, Bangladesh
Dhaka without RICKSHAWS == C without RECURSION == NIGHTMARE to me