Betris (Large)
Problem
Betris is a strategic game where players compete in betting to acquire polyomino blocks on a board and efficiently place the acquired blocks to fill the board.
1. Board and Components
Each player starts the game with one empty board and chips to be used for betting.

The board consists of rows and columns. Rows are numbered to from top to bottom, and columns are numbered to from left to right. A cell at the -th row and -th column is denoted as . Chips can be used during the betting phase later in the game.

types of polyomino blocks are used in the game. The shapes and names of each block are shown above.
2. Game Progression
The game proceeds for a total of rounds. Each round is divided into a Betting Phase and a Placement Phase.
Phase 1: Betting Phase
- The judge selects one of the types of blocks with equal probability and designates it as . Then, it selects one of the remaining types of blocks with equal probability and designates it as .
- Each player submits their choice of block (either or ) and the number of chips they wish to bet to the judge. The number of chips bet must be between and inclusive, and cannot exceed the number of chips the player currently possesses.
- Once both players have decided on their block and chip amount, the judge determines the success of the bet according to the following rules:
- If the two players chose different blocks, both players succeed in their bets.
- If the two players chose the same block and the number of chips bet is different, the player who bet more chips succeeds.
- If the two players chose the same block and the number of chips bet is the same, the judge randomly selects one player to succeed.
- The player who succeeds in the bet acquires their chosen block and pays the number of chips they bet.
- The player who fails in the bet acquires the block they did not choose and does not pay any chips.
Phase 2: Placement Phase
- Each player can rotate their acquired block clockwise by as many times as they want.
- Each player can flip their acquired block horizontally/vertically as many times as they want.
- Afterward, the player can either place the block on the board or choose to PASS.
- If a player chooses to place the block, it must be placed within the board boundaries and on cells that are not already occupied by other blocks.
- If a player decides that it is disadvantageous to place a block even if there is space, they may select PASS.
3. Scoring
After all rounds are completed, each player's score is calculated as follows:
- point is awarded for each cell occupied by a block on the board.
- point is awarded for each cell within the largest square that can be formed using only the filled cells on the board.
- points are awarded for each remaining chip.
For example, in the following case, the player's score is points.

The final winner is the player with the higher score. If the scores are equal, the game ends in a draw.
Input
The judge program communicates with the player using single-line text commands as follows:
| Command | Judge → Player (Input) | Player → Judge (Output) | Time Limit (ms) | Description |
|---|---|---|---|---|
| READY | READY |
OK |
3000 |
Signals the start of the game. |
| PHASE1 | PHASE1 A B my_time opp_time |
BET C x |
my_time |
Informs the block pair selected by the judge and the remaining time for both players. Output your chosen block and the number of chips to bet. |
| PHASE2 | PHASE2 C my_chip opp_chip my_time opp_time |
PLACE k x1 y1 ... xk yk |
my_time |
After the betting phase, informs the acquired block, remaining chips, and time for both players. If placing a block, output the number of cells and their coordinates. Output PLACE 0 to PASS. |
| OPP | OPP k x1 y1 ... xk yk |
- | - | After the placement phase, informs the move made by the opponent. |
| FINISH | FINISH |
- | - | Signals the end of the game. The player must terminate normally without further output. |
- The READY command is given once before the st round starts, and the FINISH command is given once after the th round ends.
- The PHASE1, PHASE2, and OPP commands are given once per round in order.
For the PHASE1 command:
- Input
A,Bwill be one of:I1,I2,I3,L3,I4,L4,S4,T4,O4,I5,L5,F5,N5,P5,T5,U5,V5,W5,X5,Y5,Z5. - Input
AandBare always different. - Output
Cmust be eitherAorB. - Output
xmust be an integer between and inclusive and cannot exceed your current chip count.
For the PHASE2 command:
- Input
Cis the block you acquired (one of theAorBfrom the previous PHASE1). - Output
k x1 y1 ... xk ykmust be space-separated integers. - If , must equal the number of cells in block
C. - If , the following integers represent the coordinates of the cells where the block is placed, which must be valid according to the rules.
General I/O Rules:
my_chip,opp_chip,my_time,opp_time, andtimeare all integers.- All times are in milliseconds.
- After every output, you must print a newline character and flush the buffer.
- Failure to output within the time limit results in a Time Limit Exceeded (
TLE) verdict. - Outputting an invalid format results in a Runtime Error (
RE) verdict.
Example
| P1 Input | P1 Output | P2 Input | P2 Output |
|---|---|---|---|
READY |
READY |
||
OK |
OK |
||
PHASE1 I2 F5 10000 10000 |
PHASE1 I2 F5 10000 10000 |
||
BET F5 4 |
BET F5 4 |
||
PHASE2 F5 20 24 9999 9999 |
PHASE2 I2 24 20 9999 9999 |
||
PLACE 5 1 1 1 2 2 2 2 3 3 2 |
PLACE 2 1 1 1 2 |
||
OPP 2 1 1 1 2 |
OPP 5 1 1 1 2 2 2 2 3 3 2 |
||
PHASE1 P5 L3 9998 9998 |
PHASE1 P5 L3 9998 9998 |
||
BET P5 5 |
BET L3 2 |
||
PHASE2 P5 15 22 9997 9997 |
PHASE2 L3 22 15 9997 9997 |
||
PLACE 5 1 3 1 4 1 5 2 4 2 5 |
PLACE 3 1 3 1 4 2 3 |
||
OPP 3 1 3 1 4 2 3 |
OPP 5 1 3 1 4 1 5 2 4 2 5 |
||
FINISH |
FINISH |
Sample Code
- C20 : sample.c
- CPP20 : sample.cpp
- PYTHON3, PYPY3 : sample.py
Limit
- Time: For the first PHASE1 command given to each player,
my_timeis ms. - Memory: 1024MB
- Judging Environment: HELP > Judging Environment
