LCC '25 Contest 3 J3 - Snowball Competition
View as PDFThe annual Lyon's Cold Competition (LCC) has begun!
Today's event takes place on a rectangular field with rows and
columns. Every cell in the field contains
layers of snow. Each layer has a fixed thickness, and snow is removed from the upper layers first.
There are competitors, numbered from
. Each competitor controls one snowball that starts at a given position (
,
) on the grid. Every competitor always faces one of the four cardinal directions: north, east, south, or west. The competitor begin by facing north, and whenever they push their snowball their snowball moves in the direction that the competitor is facing. All snowballs start with size zero.
Each cell begins with unused snow layers. When a snowball gets pushed onto a cell, the next unused snow layer on that cell is removed and added to the size of the snowball. If all
layers on a cell have already been removed, then the snowball gains no snow when moving onto that cell.
Throughout the event events unfold. Each event applies to exactly one competitor and describes one of the following actions:
PUSH, TURN_RIGHT, or TURN_LEFT.
When a competitor is doing the action of:
PUSH, the competitor and their snowball attempt to move forward by one cell in the direction the competitor is currently facing. If the target cell is outside the grid, neither move nor gain snow. If the snowball successfully moves into a new cell, it collects snow from that cell according to the snow layer rules.TURN_RIGHT, the competitor turns 90 degrees to their right (clockwise) to face another direction.TURN_LEFT, the competitor turns 90 degrees to their left (counter clockwise) to face another direction.
Multiple snowballs may occupy the same cell at the same time. Instructions are processed strictly in the order given.
As the event organizor, your task is to determine the size of the largest snowball.
Input Specification
The first line will contain the single spaced integers
,
,
,
, and
- the number of rows, columns, snow levels, competitors and events.
The next line will contain single spaced integers, describing the
layer of snow for each cell from top to bottom.
The next lines will contain two single spaced integers
and
, describing the position of the
competitor and their snowball.
The next line will describe an event and will contain an integer
and a string
- the competitor and action they have done.
Output Specification
On a single line output the size of the largest snowball(s).
Constraints
Sample Input
10 10 3 5 14
42 71 43
10 3
10 2
4 6
9 1
5 8
5 TURN_LEFT
4 PUSH
1 TURN_RIGHT
4 PUSH
1 TURN_LEFT
2 TURN_LEFT
2 PUSH
1 TURN_LEFT
4 PUSH
3 PUSH
3 PUSH
3 TURN_LEFT
3 TURN_LEFT
3 PUSH
Output for Sample Input
155
Explanation of Output for Sample Input
Competitor ends up having a snowball of size
.
Competitor ends up having a snowball of size
.
Competitor ends up having a snowball of size
.
Competitor ends up having a snowball of size
.
Competitor ends up having a snowball of size
.
Therefore, the largest snowball is of size .
Comments