G. Gravitational Tetris

Codeforces
IDCF10152G
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Gravitational Tetris is a Tetris variant that individual blocks can freely fall to the bottom. Therefore the game state of Gravitational Tetris can be described by an array of 10 integers, each representing the number of blocks (the height) of the column. The columns are numbered from 1 to 10. For example, the game state below can be described by the array [1, 5, 3, 0, 2, 0, 3, 1, 0, 1]. You are given a valid Gravitation Tetris game state. Your task is to continue to play the game such that all blocks are eliminated. A row will be eliminated when there are 10 blocks in the row. Since the blocks can freely fall, there are only 8 distinct Tetrominoes (shapes), with all rotations taken into account. The letter below each Tetromino denotes its type and its left-most column. In each move, you should select a Tetromino type and a column number c. For type A, it will fall onto column c. For type B, it will fall onto columns c, c + 1, c + 2 and c + 3. For type C, E and G, it will fall onto columns c and c + 1. For type D, F and H, it will fall onto columns c, c + 1 and c + 2. For example, from the above game state, after choosing type G and column 4, it will become: You are allowed to use at most 1000 moves and there is no height restriction. Completed rows will be eliminated automatically. The input consists of 10 integers, H1, H2, ..., H10 – the height of the columns from left to right. It is guaranteed that it is a valid game state and a solution exists. 0 ≤ Hi ≤ 12. At least one of them is 0 but their sum is not 0. Output any sequence of moves that can eliminate all blocks. You are not required to minimize the number of moves. In the first line output a single integer M – the number of moves. In each of the next M lines output the type of Tetromino (_A_ to _H_), a space, then the column number (1 to 10). Your answer will be regarded as incorrect if the column number is invalid for the type (e.g. column 8, 9 or 10 for type B). Explanation for Sample 1: Explanation for Sample 2: ## Input The input consists of 10 integers, H1, H2, ..., H10 – the height of the columns from left to right. It is guaranteed that it is a valid game state and a solution exists.0 ≤ Hi ≤ 12. At least one of them is 0 but their sum is not 0. ## Output Output any sequence of moves that can eliminate all blocks. You are not required to minimize the number of moves.In the first line output a single integer M – the number of moves.In each of the next M lines output the type of Tetromino (_A_ to _H_), a space, then the column number (1 to 10). Your answer will be regarded as incorrect if the column number is invalid for the type (e.g. column 8, 9 or 10 for type B). [samples] ## Note Explanation for Sample 1: Explanation for Sample 2:
**Definitions** Let $ H = (H_1, H_2, \dots, H_{10}) \in \mathbb{Z}_{\geq 0}^{10} $ be the initial column heights, with $ \sum_{i=1}^{10} H_i > 0 $ and $ \exists i: H_i = 0 $, $ 0 \leq H_i \leq 12 $. Let $ \mathcal{T} = \{A, B, C, D, E, F, G, H\} $ be the set of Tetromino types. For each type $ T \in \mathcal{T} $, define its footprint $ f(T, c) \subseteq \{1, \dots, 10\} $ as the set of columns it occupies when placed at column $ c $: - $ f(A, c) = \{c\} $ - $ f(B, c) = \{c, c+1, c+2, c+3\} $ - $ f(C, c) = f(E, c) = f(G, c) = \{c, c+1\} $ - $ f(D, c) = f(F, c) = f(H, c) = \{c, c+1, c+2\} $ Each placement of type $ T $ at column $ c $ increases the height of each column $ j \in f(T, c) $ by 1. After each move, any row with exactly 10 blocks across all 10 columns is cleared (all columns lose 1 block in that row; multiple rows may clear simultaneously). **Constraints** 1. $ 1 \leq M \leq 1000 $ (number of moves) 2. For each move $ (T, c) $: - $ T \in \mathcal{T} $ - $ c \in \{1, \dots, 10\} $ - $ f(T, c) \subseteq \{1, \dots, 10\} $ (i.e., no out-of-bounds placement) 3. Initial state $ H $ is valid and a solution exists. **Objective** Find a sequence of $ M $ moves $ (T_1, c_1), (T_2, c_2), \dots, (T_M, c_M) $ such that, after applying all moves and automatic row clears, the final state is $ (0, 0, \dots, 0) $.
API Response (JSON)
{
  "problem": {
    "name": "G. Gravitational Tetris",
    "description": {
      "content": "Gravitational Tetris is a Tetris variant that individual blocks can freely fall to the bottom. Therefore the game state of Gravitational Tetris can be described by an array of 10 integers, each repres",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10152G"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Gravitational Tetris is a Tetris variant that individual blocks can freely fall to the bottom. Therefore the game state of Gravitational Tetris can be described by an array of 10 integers, each repres...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ H = (H_1, H_2, \\dots, H_{10}) \\in \\mathbb{Z}_{\\geq 0}^{10} $ be the initial column heights, with $ \\sum_{i=1}^{10} H_i > 0 $ and $ \\exists i: H_i = 0 $, $ 0 \\leq H_i \\leq 12 $....",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments