Source: RMO-2024-P5
Category: Extremal Problems

Problem: A garden consists of a $10\times10$ grid of squares. On New Year's Eve, it begins to snow, and from that point on, every night $10$ cm of snow falls on each square (snow only falls at night). Every morning, the gardener chooses one row or one column and shovels all the snow from it onto an adjacent row or column, with the rule that snow cannot be shoveled outside the garden. On the evening of the $100$th day of the new year, an inspector will arrive and find the highest snow pile. The gardener's goal is to minimize this height. Find the height of the snow pile found by the inspector. Note: The snow does not melt during these $100$ days.

Answer: 1120 centimeters

Reference solution:
On the morning of day $100$, the caretaker clears the snow from an entire row or column. Since snow only falls at night, by the evening of day $100$ (when the inspector arrives), there are $10$ cells in that cleared row or column with $0$ cm of snow. 

Over the $100$ days, a total of $100 \times 100$ units of $10$-centimeter snow has fallen on the garden. Since the total amount of snow is conserved (none is shoveled outside or melts), these $10,000$ units of snow must be distributed among the remaining at most $90$ cells. By the averaging principle, there must be at least one cell containing at least
$$ 10 \left\lceil \frac{100 \times 100}{90} \right\rceil = 10 \lceil 111.11\dots \rceil = 1120 \text{ cm} $$
of snow. Thus, the maximum height of a snow pile is at least $1120$ cm.

We can achieve exactly $1120$ cm with the following strategy:
- In the first $11$ days (days $1$ to $11$), the caretaker sweeps all the snow from the second column into the first column.
- In the next $11$ days (days $12$ to $22$), the caretaker sweeps all the snow from the third column into the second column.
- In general, for each $k = 1, 2, \dots, 9$, during the $11$ days from day $11k - 10$ to day $11k$, the caretaker sweeps all the snow from column $k+1$ into column $k$.

Let us track the amount of snow in each column. We claim that after $11k$ days, each cell in columns $1$ through $k$ has $110(k+1)$ cm of snow, each cell in column $k+1$ has $0$ cm, and each cell in columns $k+2$ through $10$ has $110k$ cm. We proceed by induction on $k$:
- **Base case ($k=1$)**: During the first $11$ days, column $2$ is swept to column $1$ every morning. Each day, column $1$ receives its own $10$ cm of snowfall plus the $10$ cm of snow swept from column $2$, accumulating $20 \times 11 = 220$ cm. Column $2$ is cleared every morning and thus ends with $0$ cm. Columns $3$ through $10$ are untouched and each accumulate $10 \times 11 = 110$ cm. The claim holds.
- **Inductive step**: Suppose the claim holds for $k$. During the next $11$ days (days $11k+1$ to $11k+11$), column $k+2$ is swept into column $k+1$.
  On the morning of day $11k+1$, column $k+2$ has its previous $110k$ cm plus $10$ cm from the overnight snowfall, totaling $110k + 10$ cm. This is swept into column $k+1$, which also received $10$ cm overnight. Thus, column $k+1$ now holds $10 + 110k + 10 = 110k + 20$ cm.
  For the remaining $10$ days of this $11$-day period, column $k+1$ receives its own $10$ cm plus the $10$ cm from column $k+2$ each day, gaining an additional $20 \times 10 = 200$ cm. Thus, column $k+1$ reaches $110k + 20 + 200 = 110(k+2)$ cm.
  Column $k+2$ is cleared every morning and ends with $0$ cm.
  Columns $1$ through $k$ simply accumulate $10$ cm each night for $11$ nights, adding $110$ cm to reach $110(k+1) + 110 = 110(k+2)$ cm.
  Columns $k+3$ through $10$ also accumulate $110$ cm, reaching $110k + 110 = 110(k+1)$ cm.
  This completes the induction.

Applying this for $k=9$, after $99$ days, each cell in columns $1$ through $9$ has $110(10) = 1100$ cm of snow, and each cell in column $10$ has $0$ cm. 

On day $100$, $10$ cm of snow falls on all columns overnight. Columns $1$ through $9$ now have $1110$ cm, and column $10$ has $10$ cm. In the morning, the caretaker sweeps the snow from the tenth column into the ninth column. Each cell in column $9$ receives the $10$ cm from column $10$, reaching $1110 + 10 = 1120$ cm. Column $10$ is left with $0$ cm, and columns $1$ through $8$ remain at $1110$ cm. 

Therefore, on the evening of the $100$th day, the maximum snow pile height found by the inspector is exactly $1120$ cm.

Grading guidelines:
(Partial) 1. Observed that on day 100 the gardener can create (at least) 10 cells with 0 cm by choosing a whole row/column to be cleared that morning, and used this to reduce the final distribution to at most 90 nonzero cells. 2. Used conservation of total snow and an averaging/pigeonhole argument to obtain a nontrivial lower bound for the maximum pile (e.g. deriving the bound 1120 cm, or correctly setting up 10000 units over 90 cells). 3. Gave a concrete, checkable shoveling strategy that keeps the maximum height bounded by a specific value close to the optimum (even if not proved optimal), e.g. a systematic column-by-column shifting plan. (Almost) 1. Proved the correct lower bound 1120 cm, but the construction is incomplete (e.g. strategy described but not tracked rigorously to ensure no cell exceeds 1120). 2. Presented the intended 11-day-per-column shifting strategy (or equivalent) and tracked column heights to reach a maximum of 1120 cm, but with a small arithmetic/indexing error (such as miscounting 99 vs 100 days) that is localized and fixable. 3. Gave both a correct lower bound via averaging and a near-complete matching strategy, but omitted a boundary check (e.g. the final day’s move or the fact that shoveling is to an adjacent row/column only) while the rest of the argument is correct.

Construction task:
Provide an explicit 100-day morning operation schedule that achieves the optimal minimization objective from the original problem.

Output exactly one construction block with ONLY a Python literal list of length 100 between the tags <construct> and </construct>. Each element must be a 3-tuple (kind, idx, dir) where:
- kind is the string "R" (row) or "C" (column),
- idx is an integer in {0,1,...,9} indicating which row/column is selected,
- dir is either -1 or +1 indicating shoveling to the adjacent row/column with index idx+dir.

Operational meaning to be verified (do not restate as extra text inside the construction):
- Nights: for each day d = 1..100, before the morning operation, every one of the 100 squares gains +10 cm of snow.
- Mornings: then execute the scheduled operation for that day: choose the specified full row/column, remove all its snow and add it cellwise onto the adjacent target row/column (same columns for a row move; same rows for a column move). The source row/column becomes 0 afterwards. Snow may not be shoveled outside the 10x10 grid, so idx+dir must be in {0..9}.

The verifier will simulate all 100 days in this time order and then compute, on the evening of day 100 (i.e., after the 100th morning operation), the maximum snow height over all squares; your schedule must attain the optimal bound for this instance.

Reference construction:
[('R', 0, 1), ('R', 6, 1), ('R', 1, 1), ('R', 8, -1), ('R', 8, 1), ('R', 3, -1), ('R', 6, -1), ('R', 8, 1), ('R', 5, 1), ('R', 9, -1),
 ('R', 1, -1), ('R', 1, -1), ('R', 8, 1), ('R', 5, -1), ('R', 4, 1), ('R', 1, -1), ('R', 2, -1), ('R', 3, -1), ('R', 7, 1), ('R', 6, 1),
 ('R', 3, -1), ('R', 3, 1), ('R', 6, 1), ('R', 6, -1), ('R', 5, 1), ('R', 2, 1), ('R', 3, -1), ('R', 3, -1), ('R', 4, 1), ('R', 3, 1),
 ('R', 3, -1), ('R', 3, -1), ('R', 4, 1), ('R', 4, -1), ('R', 4, -1), ('R', 4, -1), ('R', 4, -1), ('R', 4, 1), ('R', 4, -1), ('R', 4, -1),
 ('R', 4, -1), ('R', 4, -1), ('R', 4, 1), ('R', 4, 1), ('R', 4, -1), ('R', 3, 1), ('R', 3, 1), ('R', 3, 1), ('R', 4, -1), ('R', 4, -1),
 ('R', 4, -1), ('R', 4, -1), ('R', 4, 1), ('R', 4, 1), ('R', 3, 1), ('R', 3, -1), ('R', 4, -1), ('R', 4, -1), ('R', 4, -1), ('R', 4, -1),
 ('R', 4, -1), ('R', 4, 1), ('R', 4, -1), ('R', 4, -1), ('R', 3, 1), ('R', 4, -1), ('R', 3, 1), ('R', 3, 1), ('R', 3, 1), ('R', 3, -1),
 ('R', 3, 1), ('R', 4, -1), ('R', 3, 1), ('R', 3, -1), ('R', 4, -1), ('R', 4, -1), ('R', 3, 1), ('R', 4, -1), ('R', 4, -1), ('R', 5, -1),
 ('R', 5, -1), ('R', 5, -1), ('R', 5, 1), ('R', 4, 1), ('R', 3, 1), ('R', 4, -1), ('R', 5, -1), ('R', 5, 1), ('R', 4, 1), ('R', 4, -1),
 ('R', 3, 1), ('R', 4, -1), ('R', 4, 1), ('R', 5, -1), ('R', 4, 1), ('R', 3, 1), ('R', 3, -1), ('R', 3, 1), ('R', 2, 1), ('R', 3, -1)]

Verifier code:
import sys, ast

TARGET_MAX = 1120
N = 10
DAYS = 100
FALL = 10

def fail(msg: str):
    print(msg)
    sys.exit(0)

def main():
    s = sys.stdin.read()
    if s.strip() == "":
        fail("Parse error: empty input (expected a Python literal list).")
    try:
        obj = ast.literal_eval(s)
    except Exception as e:
        fail(f"Parse error: {e}")

    if not isinstance(obj, list):
        fail(f"Validation error: expected a list, got {type(obj).__name__}.")
    if len(obj) != DAYS:
        fail(f"Validation error: expected list of length {DAYS}, got {len(obj)}.")

    # grid[r][c] in centimeters
    grid = [[0 for _ in range(N)] for _ in range(N)]

    for day in range(DAYS):
        step = obj[day]
        if not isinstance(step, (tuple, list)) or len(step) != 3:
            fail(f"Validation error (day {day+1}): expected a 3-tuple/list (kind, idx, dir).")
        kind, idx, direction = step

        if kind not in ("R", "C"):
            fail(f"Validation error (day {day+1}): kind must be 'R' or 'C'.")
        if not isinstance(idx, int):
            fail(f"Validation error (day {day+1}): idx must be an int.")
        if idx < 0 or idx >= N:
            fail(f"Validation error (day {day+1}): idx out of range 0..9.")
        if direction not in (-1, 1):
            fail(f"Validation error (day {day+1}): dir must be -1 or +1.")
        dst = idx + direction
        if not isinstance(dst, int) or dst < 0 or dst >= N:
            fail(f"Validation error (day {day+1}): illegal destination idx+dir={dst} (must be 0..9).")

        # Night snowfall
        for r in range(N):
            row = grid[r]
            for c in range(N):
                row[c] += FALL

        # Morning operation
        if kind == "R":
            src = idx
            tgt = dst
            src_row = grid[src]
            tgt_row = grid[tgt]
            for c in range(N):
                tgt_row[c] += src_row[c]
                src_row[c] = 0
        else:  # kind == "C"
            src = idx
            tgt = dst
            for r in range(N):
                grid[r][tgt] += grid[r][src]
                grid[r][src] = 0

        # Nonnegativity sanity
        for r in range(N):
            for c in range(N):
                if grid[r][c] < 0:
                    fail(f"Validation error (day {day+1}): negative snow height encountered.")

    mx = max(max(row) for row in grid)
    if mx != TARGET_MAX:
        fail(f"Validation failure: final maximum snow height is {mx} cm, expected {TARGET_MAX} cm.")
    print("True")

if __name__ == "__main__":
    main()