|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|4 초||512 MB||37||12||9||26.471%|
High-rise buildings in the wealthy retail district of Knightsbridge are usually built with exotic hoisting machines known, in construction circles, as cranes.
While it is common to mount these devices on the ground, it’s not always ideal—for example, a skyscraper building would need an equally tall crane. In these cases, the clever solution the industry has developed is for a smaller crane to be mounted directly on top of the tower.
However, this solution presents another challenge: how can such heavy equipment be brought to the summit in the first place? The industry’s solution is to simply use a smaller crane to lift the main crane up. And if that smaller crane is still too massive, find another smaller still, and so on, until said device fits inside a pocket and can be carried up by some enterprising engineer.
Once on top of the building, whether by being carried up, or by being lifted up by another crane capable of holding its weight, a crane can be used to lift others up onto its tower. Once raised, it is not possible to transfer a crane anywhere else.
We have several construction projects in progress at the moment, each with its own requirements on how heavy the loads eventually lifted from the ground need to be. Find an assignment of cranes to buildings that can satisfy these requirements.
If it is not possible to supply all of the buildings, output impossible.
Otherwise, output M lines. The i-th line should contain a list of space-separated integers x1 . . . xk (1 ≤ x ≤ N), describing the order in which cranes should be raised onto the i-th building from the input.
5 0 1 1 2 2 3 3 4 0 2 2 4 2
5 3 4 1 2
7 0 1 1 4 0 3 0 1 2 5 2 5 1 2 3 5 4 5
3 5 1 2 4 7 6
2 0 1 5 3 2 2 1