#CT0000129. Trò chơi khối hộp (Cuboid Game)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Trò chơi khối hộp (Cuboid Game)
Cuboid Game
Source: Bộ Giáo dục và Đào tạo
Version: Phuoc Hung OJ Extended
Problem Statement
The game uses a rectangular cuboid with edge lengths and a board of rows and columns. Rows increase from top to bottom, columns from left to right, both starting at .
Initially the cuboid rests on its face, covering every cell in the rectangle from to . In each move the player may slide the cuboid by one cell up, down, left, or right, or roll it over one of the four edges of its bottom face. Rolling may change which pair of dimensions forms the bottom face, but the same cuboid is used throughout.
Initially all cells under the cuboid are lit green, other cells are marked red, and the rest are unlit. A move is legal only if the new footprint lies completely inside the board and does not cover any red cell. Whenever a legal move finishes, all cells under the cuboid become green; previously green cells remain green.
Any sequence of legal moves may be performed, with no prescribed length. Find the maximum possible number of green cells.
Input
- The first line contains six positive integers .
- The next lines contain , the row and column of red cell .
Output
Print one integer: the maximum number of cells that can be lit green.
Subtasks
- Subtask 1 (25 points): ; ; ; ; ; ; red cells are distinct and outside the initial footprint.
- Subtask 2 (25 points): ; ; ; ; ; ; red cells are distinct and outside the initial footprint.
- Subtask 3 (25 points): ; ; ; ; ; red cells are distinct and outside the initial footprint.
- Subtask 4 (25 points): ; ; ; ; ; red cells are distinct and outside the initial footprint.
Examples
Example 1
Input
1 2 1 3 3 2
2 2
3 3
Output
7
Explanation: The initial footprint covers and . Red cells are and . A legal sequence of rolls and slides reaches the other cells, and no more than is possible because of the board cells are red.
Liên quan
Trong các cuộc thi sau: