#P15101. [ICPC 2025 LAC] Game of Pieces
[ICPC 2025 LAC] Game of Pieces
题目描述
If you’ve ever played Tetris for long enough, you might have experienced the Tetris effect – seeing falling blocks even after you have stopped playing. To stay focused on solving problems and avoid such distractions, we will consider a simplified version of the game.
The game is played on a board composed of square cells arranged in a grid. Columns of the grid are numbered sequentially from left to right. The board is infinite to the right and to the top. Each cell is either empty or filled, and initially, all cells are empty.
A sequence of rectangular pieces is given, and the pieces are dropped onto the board one at a time. Pieces have different sizes. A piece of size is either vertical ( cells) or horizontal ( cells). When a piece is dropped at a specified column, it starts at a location above all the currently filled cells and falls straight down until it either reaches the bottom of the board or lands on top of an already filled cell. Once a piece lands, it fills its final set of cells.
Each time a piece lands, the game is considered safe if no empty cell has a filled cell above it; otherwise the game is unsafe, the offending piece is removed from the board, and the game continues with the next piece as if it had never been dropped.
In the example below, corresponding to the first sample input, the game becomes unsafe once the second piece lands, hence the piece is removed and the next pieces keep the game safe.
:::align{center}
:::
Given the sequence of pieces and their drop positions, your task is to determine, for each piece, whether it makes the board unsafe after landing.
输入格式
The first line contains an integer (), indicating the number of pieces.
Each of the next lines describes a piece with a character and two integers and ( and ), representing respectively the type of the piece, its length, and the position where it is dropped. For a vertical piece, is the character “|” (pipe), the piece has cells, and it is dropped at column . For a horizontal piece, is the character “-” (hyphen), the piece has cells, and it is dropped spanning columns .
输出格式
Output a single line with a string of length . The -th character of the string must be the uppercase letter “U” if the game becomes unsafe immediately after the -th piece lands on the board, and the uppercase letter “S” otherwise.
4
| 3 1
- 2 1
| 3 2
- 2 1
SUSS
4
| 3 1
| 2 3
| 1 2
- 2 2
SSSU