#FW0000025. Công ty Scrooge (The Scrooge Co Problem)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Công ty Scrooge (The Scrooge Co Problem)
The Scrooge Co Problem
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A delivery company has named locations and a directed travel-cost matrix, where means no direct connection. For each employee, find a route from the requested origin to the destination, following directed edges only. The reimbursement is the minimum total cost of the roads used. Output the complete route, or an explicit impossibility message when the destination cannot be reached.
Input
, one tab-separated line of location names, an matrix, , then rows employee start destination (single-token names in PHOJ).
Output
For employee name traveling from start to end, if reachable, print two lines in the exact format:
Mr name to go from start to end, you will receive C euros
Path: start ... end
Here is the minimum travel cost, and the path is the complete sequence of location names separated by spaces. Any optimal route is valid when several exist. If unreachable, print only:
Sorry Mr name you can not go from start to end
Process requests in the given order.
Subtasks
- Subtask 1 (40 points): ; ; ; .
- Subtask 2 (60 points): ; ; .
Examples
Input
2
A B
0 3
-1 0
2
John A B
Anna B A
Output
Mr John to go from A to B, you will receive 3 euros
Path: A B
Sorry Mr Anna you can not go from B to A
Explanation
John can travel A to B for euros. Anna cannot travel B to A because the reverse road is missing.