#P15101. [ICPC 2025 LAC] Game of Pieces

    ID: 17019 远端评测题 2500ms 1024MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>线段树树状数组2025离散化差分ICPC

[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 NN rectangular pieces is given, and the pieces are dropped onto the board one at a time. Pieces have different sizes. A piece of size LL is either vertical (L×1L \times 1 cells) or horizontal (1×L1 \times L 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 NN (1N21051 \le N \le 2 \cdot 10^5), indicating the number of pieces.

Each of the next NN lines describes a piece with a character CC and two integers LL and PP (1L1091 \le L \le 10^9 and 1P10181 \le P \le 10^{18}), representing respectively the type of the piece, its length, and the position where it is dropped. For a vertical piece, CC is the character “|” (pipe), the piece has L×1L \times 1 cells, and it is dropped at column PP. For a horizontal piece, CC is the character “-” (hyphen), the piece has 1×L1 \times L cells, and it is dropped spanning columns P,P+1,,P+L1P, P+1, \dots, P+L-1.

输出格式

Output a single line with a string of length NN. The ii-th character of the string must be the uppercase letter “U” if the game becomes unsafe immediately after the ii-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