You have given the net consisting of nodes and pipes; pipes connect the nodes. Some substance can flow by pipes, and flow speed in any pipe doesn't exceed capacity of this pipe.
The substance cannot be accumulated in the nodes. But it is being produced in the first node with the non-negative speed and being consumed with the same speed in the last node.
You have some subset taken from the set of pipes of this net. You need to start the motion of substance in the net, and your motion must fully fill the pipes of the given subset. Speed of the producing substance in the first node must be minimal.
Calculate this speed and show the scene of substance motion.
Remember that substance can't be accumulated in the nodes of the net.
Warn: 本題有 specialjudge
There may be multiple testcases.
Each testcase begins with two positive integer numbers N (1<=N<=100) and M in the first line of the input - numbers of nodes and pipes.
lines follows: each line contains four integer numbers Ui, Vi, Zi, Ci; the numbers are separated by a space. Ui is the beginning of i-th pipe, Vi is its end, Zi is a capacity of i-th pipe (1<=Zi<=105) and Ci is 1 if i-th pipe must be fully filled, and 0 otherwise.
Any pair of nodes can be connected only by one pipe. If there is a pipe from node A to node B, then there is no pipe from B to A. Not a single node is connected with itself.
Substance can flow only from the beginning of a pipe to its end.
For each testcase, write one integer number in the first line of the output - it ought to be the minimal speed of the producing substance in the first node.
Write M integers in the second line - i-th number ought to be the flow speed in the i-th pipe (numbering of pipes is equal to the input).
If it is impossible to fill the given subset, write "Impossible" in one line.
4 4 1 2 2 0 2 4 1 1 1 3 2 1 3 4 3 0 4 4 1 2 1 0 2 4 2 1 1 3 3 1 3 4 2 0
3 1 1 2 2 Impossible
Migrated from old NTUJ.
sgu176
No. | Testdata Range | Score |
---|