|
||||||||||
MaginaTime Limit: 60000/30000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1147 Accepted Submission(s): 404 Problem Description Magina, also known as Anti-Mage, is a very cool hero in DotA (Defense of the Ancient). If you have no idea of him, here is some brief introduction of his legendary antecedents: Twin sons to the great Prophet, Terrorblade and Magina were blessed with divine powers: Terrorblade granted with an unnatural affinity with life forces; Magina gifted with energy manipulation. Magina's eventual overexposure to the magic gradually augmented his elemental resistances and bestowed him the unique ability to move faster than light itself. Now, broken by Terrorblade's fall to the dark side, Magina answers the Sentinel's call in a desperate bid to redeem his brother. Every bitter strike turns the Scourge's evil essences upon themselves, culminating in a finale that forces his enemy to awaken to the void within and spontaneously implode. Magina has a very IMBA (imbalanced) skill ¨C Blink, yes, move from one place to another place in a wink. Our problem begins at there. As a formidable hero in the later stage, Magina always farm with the wild monsters for a long time. To make the farming more efficient, Magina use Blink frequently to jump here and there. Here we assume Blink skill has no CD, that is, we can use this skill at any time we want. There are N spots of the wild monsters, and Magina can choose any one to begin. For every spots, Magina may use Ti time to kill the monsters and gain Gi units money, or he choose blink to other spots, which is known to our brilliant Magina. If the monsters in a spot were killed, it won¡¯t appear any more. Now Magina want to get M units money to but some excellent equipment, say Battle Fury for example. As a hero to save the world, there is no much time left for Magina, he wonders the minimum time for him to gain at least M units money. Input The first line contains a single integer T, indicating the number of test cases. Each test case begins with two integers N, M. Their meanings are the same as the description. Then N blocks follow, each one describes a spot of wild monsters. The first line of each block is there integers Ti, Gi and Ki. Ti is the time, Gi is the units of money, Ki is the number of spots Magina can blink to from here. Then Ki integer Cij follow, indicating the spots¡¯ ID Magina can blink to. You may assume no ID would appear twice. The spots are described with ID increasing from 1 to N. Input ensure if you can blink from i to j, you can also blink from j to i. Technical Specification 1. 1 <= T <= 50 2. 1 <= N <= 50 3. 1 <= Ti <= 10000000 4. 1 <= M, Gi <= 1000000000 5. 1 <= Ki < N 6. 1 <= Cij <= N Output For each test case, output the case number first, then the minimum time for Magina to gain at least M units money, if can¡¯t, output ¡°Poor Magina, you can't save the world all the time!¡±. Sample Input
Sample Output
Author iSea@WHU Source | ||||||||||
|