68 - ZOJ Monthly, July 2008 - 1006
Little Tom likes playing games. Recently he is fond of a game called Lamp Game. The game is like this: at first, there are n lamps on the desk, all of which are lighted and Tom is given an initial score. Each time, Tom selects one lamp and changes its state, this action will costs little Tom some percent of score. What's more, the circuit of the lamps is designed so that, when Tom changes the state of one lamp, some related lamps' states will also be changed. The object of this game is to make all lamps off and make the total lost of score as low as possible. Of course little Tom is not smart enough to solve this problem, so he asks you, a student in ZJU, to help him.
The input contains several test cases. Each case begins with two integers n and m (n<=10,0<m<=100000000), which are the number of lamps and the initial score of Tom. Then n lines follows, each in the format of t n1 n2 ...... nt f (0<=t<n,1<=ni<=n,0<=f<100). The i-th line means changing the state of the i-th lamp will make t related lamps' states changed and the following t integers give the t related lamps (these t numbers will not include i). And changing the state of the i-th lamp will cost Tom f percents of score. All numbers are integers. Two 0s of n and m signals the end of input.
For each test case, output one line containing the maximum score Tom has when he finished the game successfully. The result should be accurate to 2 decimal places. If Tom cannot finish this game, simply output -1.
3 100 1 2 50 0 50 1 2 50 0 0
Author: XU, Jun