시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 176 | 32 | 25 | 22.124% |
You found a box with old games when cleaning up your attic, and among them was also a jigsaw puzzle. Unfortunately, the packaging was damaged, so a couple of puzzle pieces are scattered around the bottom of the box, and you suspect that some of the pieces may have been lost elsewhere. In fact, given the orderliness of your attic, some of the pieces in the box may even come from some entirely different puzzle! So now you have a pile of puzzle pieces lying in front of you and you are trying to assemble them into a solved puzzle.
Figure J.1: Illustration of the first sample.
More formally:
The input consists of:
A connection of type 0 stands for a straight edge. The other connection types are numbered with consecutive positive integers starting from 1 and each of them occurs exactly two times, on two different lines.
If the pieces cannot be assembled as described above, output impossible. Otherwise, output the solved puzzle in the following format:
Any rotation of the correct solution will by accepted.
6 0 0 1 6 0 7 4 0 0 0 2 1 5 3 0 6 3 7 0 0 4 5 2 0
2 3 1 4 5 3 6 2
4 0 0 1 2 0 0 2 3 0 0 3 4 0 0 1 4
impossible