ROIM - Boa viagem, Roim
Computer Engineering student Roim is getting ready for a trip to Mexico. For that, he has studied the airplane network, so he knows the details of all R regular flights currently in operation on all of the N available airports. Unfortunately, one of his school mates is very annoying and keeps saying the same stuff to him all the time.
To solve that issue, he will organize two different flight plans: one for the team and one for the annoying guy. The condition is that the flight plans may not contain the same flight (note that it is possible for both to pass through the same airport, and that the same flight may not be used by both even if the times are different). As this may not be possible using only regular flights, he has also considered using some of the C flights chartered by travel agencies, but he'd like to keep those to a minimum as they usually suffer from large delays. Of course, as long as the least number of chartered flights is picked, Roim will pick the plans with the least total cost (defined as the sum of the costs of all flights used).
Input
The input consists of several test cases. On the first line of a test case are three integers N (2 ≤ N ≤ 225), R and C (0 ≤ R+C ≤ N(N-1)/2) separated by spaces. The starting airport is 0, and the destination is N-1.
The next R lines contain integers a, b (0 ≤ a, b ≤ N-1), c (1 ≤ c ≤ 100), meaning that there exists a one-way regular flight between airports a and b, with cost c. The following C lines give details for chartered flights in the same manner. There is a blank line at the end of each test case. The last test case is followed by a line containing three zeros.
You may assume that any pair of cities is only connected in at most a single direction by a single flight.
Output
If it is possible to make the plans, print two integers separated by spaces. The first should be the minimum amount of chartered flights used, and the second is the total cost of the solution.
If it's impossible that both the team and the guy get to their destination, print "Boa viagem, Roim" instead.
Example
Input: 4 5 0
0 1 1
1 3 5
0 2 5
1 2 1
2 3 1
4 4 1
0 1 2
1 3 2
0 2 2
1 2 1
2 3 2
2 1 0
0 1 10
0 0 0
Output: 0 12
1 8
Boa viagem, Roim
hide comments
Fernando Fonseca [ITA]:
2015-05-02 08:11:14
As min_25 pointed out, something weird happened with TL adjustment and none of the solutions that had passed on Pyramid were passing on Cube (I guess SPOJ should have added some sort of sanity check on TL readjustment).
|
|
LeBron:
2015-05-02 00:34:28
@RandomUsername
|
|
RandomUsername:
2015-05-02 00:12:32
@LeBron
|
|
LeBron:
2015-05-02 00:02:27
@Min_25
|
|
Min_25:
2015-05-01 23:27:13
@bubblecup
|
|
LeBron:
2015-05-01 19:17:58
I guess TL is OK, looks like author set this TL to prevent stupid solutions from passing (and making TL challenging was his goal, because otherwise problem becomes too easy).
|
|
RandomUsername:
2015-05-01 17:53:59
C++ scanf can't read the whole input file in time, are you sure about the time limit? |
|
fcdkbear:
2015-05-01 17:10:16
Time limit is definitely too strict. Are you sure it must be 0.027 seconds? |
|
hunguk:
2015-05-01 12:41:51
Time limit seems too strict |
|
Radhakrishnan Venkataramani:
2012-08-23 04:24:06
Suppose if The team used an airline at some time t, is the another guy allowed to use the same airline at later time ?
|
Added by: | Fernando Fonseca [ITA] |
Date: | 2012-06-13 |
Time limit: | 0.300s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |