Catch The Mouse
Problem
A fierce confrontation is taking place between a group of mice (R) and Nadori's team (C, N) on a kitchen floor.
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 .
Delicious cheese is placed at the very bottom of the board. The mice are descending the kitchen floor to eat the cheese, while the cats and Nadori are trying to stop them.

Each cell can be in one of four states: empty ., mouse R, cat C, or Nadori N. Initially, the pieces are placed as follows:
| State | Count | Initial Placement |
|---|---|---|
Mouse R |
||
Cat C |
||
Nadori N |
||
Empty cell . |
The battle begins with the mice, and Nadori and the mice take turns.
On the mice's turn, the following action is performed:
- Select a cell containing a mouse
Rand move it to .

- The destination must be an empty cell
.. - The starting cell becomes an empty cell
.. - The destination cell becomes a cell containing a mouse
R.
In essence, the mice descend one cell at a time, rushing toward the cheese.
On Nadori's turn, one of the following actions is performed:
- Select a cell containing a cat
Cand move it to .

- A cat can choose one of the directions (horizontal, vertical, or diagonal) and move along a straight path as long as there are no other pieces in the way. (i.e., the cat moves like a Queen in chess)
- The destination must be an empty cell
.. - The starting cell becomes an empty cell
.. - The destination cell becomes a cell containing a cat
C.
- Select a cell containing Nadori
Nand move it to .

- (i.e., Nadori moves like a King in chess)
- The destination must be either an empty cell
.or a cell containing a mouseR. - The starting cell becomes an empty cell
.. - The destination cell becomes a cell containing Nadori
N.
The battle ends when any of the following conditions are met:
- If any mouse reaches the th row, the mouse swarm wins and obtains the cheese.
- If all mice completely disappear from the board, Nadori's team wins.
- If there are no legal moves available for any mouse on the mice's turn, Nadori's team wins.
Please design an AI to become the ultimate winner of the kitchen floor!
Input
The judge program communicates with the agent using single-line text commands as follows:
| Command | Judge → Agent (Input) | Agent → Judge (Output) | Time Limit (ms) | Description |
|---|---|---|---|---|
| READY | READY (FIRST | SECOND) |
OK |
3000 |
Informs whether you are the first or second player. |
| TURN | TURN my_time opp_time |
MOVE x1 y1 x2 y2 |
my_time |
Informs your remaining time and the opponent's remaining time. Output the chosen and for this turn. |
| OPP | OPP x1 y1 x2 y2 time |
- | - | Informs the opponent's last move and the time they used. |
| FINISH | FINISH |
- | - | Signals the end of the game. The agent must terminate normally without further output. |
x1,y1,x2,y2are integers.my_time,opp_time, andtimeare integers representing time 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 or an illegal move during a TURN command results in a Runtime Error (
RE) verdict.
Example
| First Player Input | First Player Output | Second Player Input | Second Player Output |
|---|---|---|---|
READY FIRST |
READY SECOND |
||
OK |
OK |
||
TURN 10000 10000 |
|||
MOVE 1 1 2 1 |
|||
OPP 1 1 2 1 50 |
|||
TURN 10000 9950 |
|||
MOVE 6 6 5 7 |
|||
OPP 6 6 5 7 20 |
|||
TURN 9950 9980 |
|||
... |
|||
FINISH |
FINISH |
Sample Code
- C20: sample.c
- CPP20: sample.cpp
- PYTHON3, PYPY3: sample.py
Limit
- Time: For the first TURN command given to each agent,
my_timeis ms. - Memory: 1024MB
- Judging Environment: HELP > Judging Environment
