| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 (추가 시간 없음) | 1024 MB | 102 | 47 | 44 | 55.696% |
In the game Tetris, the goal is to position blocks falling down a grid as well as possible. Before the block falls down, the player can shift the block to the left and right, and rotate it in steps of $90$ degrees. Then, the block falls down vertically until it hits another block. Completely filling a row removes this row from the grid, clearing up space for more falling blocks.
You have played this game one too many times, and to shake things up, you decide to play Anti-Tetris: instead of controlling the positioning of the blocks falling down, the goal is to design a Tetris grid that will perfectly fit a given block. That is, a grid such that after optimally positioning the new block, all rows of the grid are cleared and no filled cells remain.
As an example, consider the first sample case, shown in Figure A.1. The input block can be rotated clockwise $90$ degrees and shifted left to make it fit exactly and clear all rows of the grid once it touches down.
Figure A.1: Visualization of the first sample case. The falling block (the input, light yellow) perfectly fits in the Tetris grid (the output, other colours).
The input consists of:
#' or '.', representing a filled or unfilled cell of the block, respectively.The input block is a single orthogonally1 connected component and exactly fits in the $w \times h$ bounding box, i.e. the first and last row and column contain at least one '#'.
1Two cells are orthogonal neighbours if and only if they are horizontal or vertical neighbours.
If there exists no Tetris grid that perfectly fits the input block, output "impossible". Else, output a grid such that placing the the input block optimally removes all rows, in the following format:
#' or '.', representing a filled or unfilled cell in the Tetris grid, respectively.A row in the output grid may not be completely filled before the block is added, since such a row would already have been removed by the game.
Note that it is not required to print empty rows at the top of the output grid, since the block can be rotated and shifted to the left and right before it falls down.
If there are multiple valid solutions, you may output any one of them.
2 3 #.. ###
3 8 ##..#### ##.##### ##.#####
2 3 .## ##.
impossible
3 3 #.. ##. ###
5 7 ....... ....... ##...## ###..## ####.##
ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2023 Preliminaries A번