시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 21 | 9 | 9 | 52.941% |
As you may know, the popular computer game “Tetris” was invented by Russian programmer Alexey Pajitnov. In this problem you need to write program which plays a simplified version of this game.
The playing field is a rectangular vertical shaft, called the “well”. Random figures of unit square blocks appear on top of the wall, the player chooses the horizontal position and rotation of the figure, after that the figure falls down in the well. The objective of the game is to create horizontal lines filled without gaps. When such a line is created, it disappears, and any blocks above the deleted line fall.
In this version of the game, the well size units, and there are only three types of figures:
Type | Figure |
---|---|
1 | |
2 | |
3 |
You lose if at some point there are five non-empty lines of the well. You win if you hadn't lost after n figures have fallen.
You need to write program which plays the game described above and wins regardless of which figures will appear.
You should implement four functions (methods):
void init(int n)
. This function is called before any other function.void new_figure(int figure_type)
. This function is called when a new figure appears. figure_type
is a number from 1 to 3, indicating the type of the figure according to the table above.int get_position()
. This function should return a number from 0 to 2, the position of the leftmost block of the last figure.int get_rotation()
. This function should return a number from 0 to 3, the number of time the figure was rotated couter-clockwise.Functions get_position
and get_rotation
will be called only after new_figure
.
The grader makes the following function calls:
init(3)
. There will be three figures.new_figure(1)
. A figure of type 1 falls from the top of the well.get_position()
returns 0. This means that player wants to put the figure in the leftmost column.get_rotation()
returns 1 (or 3). This means that player wants to rotate the figure vertically.new_figure(3)
.get_position()
returns 1.get_rotation()
returns 1.new_figure(2)
.get_position()
returns 1.get_rotation()
returns 0 (or 2).In all subtasks n ≤ 1000.
번호 | 배점 | 제한 |
---|---|---|
1 | 7 | All figures have type 1. |
2 | 8 | All figures have type 2. |
3 | 10 | All figures have type 1 or 2. |
4 | 21 | All figures have type 3. |
5 | 54 | Figures can have different types. |
The sample grader reads the input in the following format:
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)