| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 (추가 시간 없음) | 2048 MB | 40 | 9 | 7 | 35.000% |
A sliding puzzle consists of square tiles on a rectangular grid. Exactly one of the grid positions is empty, so that you can move the tile above, below, to its left, or to its right into the empty square and back.
Each tile is labelled with a unique number, as shown in Figure G.1. To solve a sliding puzzle, you need to find a sequence of moves that puts the tile numbers in ascending order, from left to right and top to bottom, such that the empty square ends up at the bottom right position in the grid, as shown in Figure G.2. Such a sequence of moves does not exist for all sliding puzzles.
While cleaning out your garage, you grapple with the garage goblins over a glowing box full of goodies. They offer a gamble: the box is yours if you can solve all their sliding puzzles. You accept to give it a go, only to find out that the garage goblins have glued some tiles in place! The glued tiles no longer move, as shown in Figure G.3.
However, all sliding puzzles share the following properties:
Determine whether it is possible to solve a given sliding puzzle.
The input consists of:
.' or '#'. The bottom right character, at the position of the empty square,.'. Otherwise, '.' denotes a tile that can move, and '#' denotes a glued tile.The set of all $a_{i,j}$ (1ドル \le i \le h, 1 \le j \le w$) contains each of the numbers 0,ドル 1, \dots, h \cdot w - 1$ once.
Output possible if the sliding puzzle can be solved, or impossible if not.
3 4 .... .... .... 10 8 2 3 6 7 5 9 11 1 4 0
possible
2 4 .... .... 2 1 3 4 5 6 7 0
impossible
3 4 ..#. .... #... 5 1 3 4 2 6 7 8 9 10 11 0
possible
3 4 ..#. .... #... 7 1 3 4 5 6 2 8 9 10 11 0
impossible
ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2024 G번