#P3342. [ZJOI2014] 璀灿光华
[ZJOI2014] 璀灿光华
Description
Mr. Jin has a girlfriend without a name. She is hardworking, brave, wise, and kind. Mr. Jin likes her very much. To this end, he used unique crystal blocks to make a crystal cube with side length . He wants to give this crystal cube to the purest and kindest girl he has ever met.
Because the crystal cube is too big to transport, Mr. Jin decided to take it apart before sending it. He believes that reassembling the crystal cube will not be difficult for her, since she is smart.
After receiving the gift, the nameless girl quickly reassembled the crystal cube according to the instructions. She found that there are crystals which, in a dark and quiet night, randomly emit a penetrating beam in one of the six directions (up, down, left, right, front, back) with equal probability. Crystals that are illuminated by the beams look especially beautiful. For each crystal that does not emit light, she defined a beauty value. The beauty of the crystal cube at night is the sum of the beauty values of all illuminated crystals. She wants to know the minimum and maximum possible beauty of the crystal cube at night.
Input Format
The first line contains , the side length of the crystal cube. Then follow lines, each containing several integers. The first number is the beauty value of the ‑th crystal. If , this crystal emits light. Then follow 3 to 6 integers, which are the indices of crystals that share a face with this crystal.
Output Format
Output two integers: the minimum and the maximum possible beauty of the crystal cube at night.
2
0 7 2 3
0 8 1 4
4 5 4 1
8 6 3 2
16 3 6 7
32 4 5 8
1 1 8 5
2 2 7 6
0 12
Hint
For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号