시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 0 | 0 | 0 | 0.000% |
You have come into possession of an irregularly-shaped piece of a stained-glass mosaic. Although the overall piece is damaged from years of storage, and missing many parts around the border, you think it would be quite nice to keep a small part of this delightful object as a souvenir.
You will find a perfectly-square subregion of this mosaic and prise it out—but only by removing pieces along the existing lines between glass panes, never by cutting into the glass.
Figure G.1: A visualisation of the first sample input. You can take a 5 × 5cm piece out from the upper-right corner.
Glass is cumbersome and you’d rather not take more than necessary. What’s the smallest square you can take out as one piece without damaging the glass?
The input consists of:
It is guaranteed that none of the given pieces of glass intersect.
Output the area of the smallest square that you can remove along existing lines, in centimetres squared. If it is not possible to remove any square at all, output impossible
instead.
13 20 16 22 19 20 15 22 16 19 14 22 15 10 10 12 20 12 10 20 14 12 14 17 15 19 15 20 18 17 18 20 19 12 19 20 20 12 15 17 17 12 17 17 18 12 18 17 19 17 14 19 18
25
4 0 0 1 9 1 0 9 1 1 8 9 9 8 1 9 8
impossible