Problem
Two players fight a duel in a courtyard. You win by knocking your opponent down, pushing them out of the courtyard, or gathering blessings at the spirit vein.
Rows and columns are numbered from to from top to bottom and from left to right, respectively, and the cell in row and column is denoted .
The courtyard has one cell called the spirit vein, where blessings can be gained. The starting positions of both players and the position of the spirit vein are chosen at random for each match. The two players start on different cells, and the spirit vein stays in the same place throughout the match.
Each player starts with health and blessings, and all techniques are available.

Example of an initial setup: Player 1 (4,3), Player 2 (4,5), spirit vein (2,4).
Turn Flow
The game lasts at most turns. Each turn, both players choose two actions in order ahead of time. Once both have chosen, the two first actions are resolved simultaneously, and then the two second actions are resolved simultaneously. If the outcome is decided while actions are being resolved, the game ends immediately.
A player standing on the spirit vein after both actions gains blessing. Blessings accumulate.

Ending the turn on the spirit vein with Move right → Wait gains 1 blessing.
Actions
Choose a direction from up, down, left, and right. Flash Step can also use the four diagonal directions. Front means the chosen direction.
| Action | Effect | Cooldown (turns) |
|---|---|---|
Wait |
Does nothing. | |
Move |
Moves one cell in the chosen direction. | |
Thrust |
Attacks the first and second cells in front, dealing damage. | |
Sweep |
Attacks the three cells in front and the two cells on either side of you, dealing damage and pushing the opponent one cell in the chosen direction. | |
Charge |
Moves one cell, then attacks the first and second cells in front, dealing damage and pushing the opponent two cells in the chosen direction. | |
Guard |
Blocks attacks from an opponent in the three cells in front or in the second cell in front. | |
Shatter |
Attacks the first cell in front. Ignores Guard, deals damage, and pushes the opponent one cell in the chosen direction. | |
Flash Step |
Moves exactly two cells in the chosen direction, passing through an opponent in the middle cell. |
Attack and Guard ranges apply only to cells inside the courtyard.

Thrust 

Sweep 

Charge 

Guard 

Shatter 

Flash Step 
The six actions other than Wait and Move are called techniques. A technique can be chosen only if it is available at the start of the turn, and the same technique can be chosen only once per turn. Move and Wait can be chosen twice.
Using a technique applies the cooldown shown in the table, whether or not it succeeds. For example, if a technique with a cooldown of is used on turn , it cannot be used on turns and , and it can be used again from turn .
- A Move or Flash Step used as the first action must head from the current position to a cell inside the courtyard. A Move or Flash Step used as the second action may choose any direction, and if its destination is outside the courtyard when it is performed, the player stays in place.
- If the destination of a Charge is outside the courtyard, the player does not move and attacks from the current position.
Simultaneous Resolution
The two players' actions are resolved in the following order.
| Order | Action | Resolution rule |
|---|---|---|
| 1 | Flash Step |
Resolve Flash Steps. |
| 2 | Guard, Thrust |
Apply Guards and determine whether Thrusts hit. An opponent hit by a Thrust that is not blocked by Guard has their movement action canceled. A Guard stays in effect while that action is being resolved. |
| 3 | Move, Charge |
Resolve Moves and the movement of Charges. |
| 4 | Sweep, Charge, Shatter |
From the positions after movement, determine whether Sweeps, Charges, and Shatters hit. |
| 5 | Attack comparison | If two attacks that are not blocked by Guard hit each other, compare their damage. If the damage differs, only the damage and push of the stronger attack are applied. If it is equal, neither side takes attack damage, and only the push of each attack is applied. |
| 6 | Push and health | Resolve pushes and health loss. Pushes proceed simultaneously one cell at a time, and if both players would land on the same cell, the remaining pushes on both sides stop. |
In each movement step, if both players' destinations are the same cell or they would swap positions, neither of them moves. A player also cannot move onto the cell of an opponent who is not moving in that step. A Charge whose movement is blocked attacks from the current position.

Thrust
vs Move
: Player 2's move is canceled and their health drops by 2.

Charge
vs Thrust
: Only the Charge's 3 damage and two-cell push are applied.

Sweep
vs Sweep
: Both sides are pushed back one cell each without taking damage.
Winning and Losing
The outcome is determined in the following order.
- After each action, a player whose health reaches or who has been pushed out of the courtyard loses. If both players meet a losing condition in the same action, the game is a draw.
- After both actions, a player whose blessings reach wins.
- If no outcome is decided by turn , the player with more blessings wins. If blessings are tied, the player with more health wins, and if both are tied, the game is a draw.

Example of pushing the opponent out of the courtyard with Charge.
Design an AI that predicts your opponent's actions and becomes the final winner of the duel!
Input
At the start of the game, both players receive the following initial setup once.
INIT objective_r objective_c r1 c1 r2 c2
objective_r objective_c are the row and column of the spirit vein, and r1 c1 and r2 c2 are the starting row and column of Player 1 and Player 2, respectively. All coordinates are integers from to .
The judge sends the following commands one line at a time.
| Command | Input | Output |
|---|---|---|
| INIT | Initial setup in the format above | - |
| READY | READY FIRST or READY SECOND |
OK |
| TURN | Current state in the format below | action1 action2 |
| FINISH | FINISH |
- |
FIRST is Player 1 and SECOND is Player 2. Exit the program when you receive FINISH or when the input ends.
Turn Input
TURN time turn r1 c1 hp1 blessing1 r2 c2 hp2 blessing2 previous_action1 previous_action2
time: remaining total response time (milliseconds).turn: the number of this turn ( to ).r1 c1 hp1 blessing1: Player 1's current row, column, health, and blessings.r2 c2 hp2 blessing2: Player 2's current row, column, health, and blessings. The input always lists Player 1 first, then Player 2.previous_action1 previous_action2: the two actions the opponent chose on the previous turn. On the first turn, this is0 0, meaning Wait, Wait.
Track cooldowns using your own choices and the opponent's previous actions received in the input.
Action Output
| Action | Output format |
|---|---|
| Wait | 0 |
| Move | 1 dir |
| Thrust | 2 dir |
| Sweep | 3 dir |
| Charge | 4 dir |
| Guard | 5 dir |
| Shatter | 6 dir |
| Flash Step | 7 dir |
dir is one of U (up), R (right), D (down), and L (left). Flash Step can also use UR (up-right), DR (down-right), DL (down-left), and UL (up-left). Wait takes no direction.
Output both actions on one line, separated by a space. For example, 1 U 2 R means Move up and then Thrust right, and 7 UR 0 means Flash Step up-right and then Wait.
Limits
- The total time spent on
READYand allTURNresponses is per player. - End each response with a newline and flush the buffer. Each response must be at most bytes, including the newline.
- Exceeding the time limit, an invalid output format, or an illegal action counts as a loss.
Example
In this example, the spirit vein is at , Player 1 starts at , and Player 2 starts at .
Both players receive the following initial input.
INIT 2 4 4 3 4 5
Player 1 receives READY FIRST and Player 2 receives READY SECOND, and each outputs OK.
The input and output for the first turn are as follows.
Player 1:
TURN 999 1 4 3 10 0 4 5 10 0 0 0
1 U 2 R
Player 2:
TURN 999 1 4 3 10 0 4 5 10 0 0 0
1 U 2 L
Both players move up and then thrust at each other. Since the damage is equal, both stay at health, and they end up at and , respectively.
The input for the second turn includes the opponent's previous actions.
Player 1:
TURN 994 2 3 3 10 0 3 5 10 0 1 U 2 L
1 U 0
Player 2:
TURN 992 2 3 3 10 0 3 5 10 0 1 U 2 R
1 U 0
This turn, both players have a Thrust cooldown of . After both actions are resolved, they are at and , respectively.
Wait
