Find trucking routes between two terminal stations.
The Truckee Freight Company has a network consisting of a number of terminal stations and transfer stations.
Consider the example shown in the figure. The main transfer station is T, and its children are B, W, D, and E. The terminal stations are F, H, R, J, K, W, L, and E. The transfer stations are T, B, M, and D.
Graph representation of the trucking network T(B(FHM(RJK))WD(L)E) |
Given the particular arrangement of routes for the Truckee Freight Company, you are to determine routes for transporting a list of customer packages.
The input file will contain a sequence of routing problems separated by a single blank line. A given routing problem will have the form:
An example input file using the network depicted in figure 1, along with a trivial routing configuration is:
column 11111111112 12345678901234567890 line 1:T(B(FHM(RJK))WD(L)E)[EOL] 2:F H[EOL] 3:R H[EOL] 4:H R[EOL] 5:J E[EOL] 6:L F[EOL] 7:[EOL] 8:M(AB)[EOL] 9:A B[EOL] 10:B A[EOL] :[EOF]
Other than the standard leader and trailer, the output file has a line of output for each line of input:
The correct output corresponding to the example input file would be:
column 111111111122222222223 123456789012345678901234567890 line 1:Program 7 by team 0[EOL] 2:T(B(FHM(RJK))WD(L)E)[EOL] 3:F->B->H[EOL] 4:R->M->B->H[EOL] 5:H->B->M->R[EOL] 6:J->M->B->T->E[EOL] 7:L->D->T->B->F[EOL] 8:[EOL] 9:M(AB)[EOL] 10:A->M->B[EOL] 11:B->M->A[EOL] 12:End of program 7 by team 0[EOL] :[EOF]