AtCoder Heuristic Contest 072

Somersault Slimes Editorial

Behind the scenes: Astra is too strong…

ALE-Bench Leaderboard, "Benchmark Results by Release Date" (sakanaai.github.io/ALE-Bench-Leaderboard, as of 2026-10-05). The ★ at the top right is gpt-6-astra-max

Behind the scenes

Survey on participation divisions (August)

Survey on participation divisions (August)

Problem

  • Leave k slimes below; the group above flips and jumps (l ≤ k+1)
  • At a nest, slimes go home from the top (at both the start and the landing cell)
  • Minimize the number of moves

01One slime at a time

  • A tower of a single slime has k = 0 → l ≤ 1
    • It can only move one cell at a time
  • Carry slimes one by one along the BFS shortest path to the nest
    • It can simply pass over towers on the way
    • Landing on a nest of another color does not send it home
  • Number of moves = sum of distances to the nests

All visualizations use seed=10

pts

02One color at a time

  • A group of a single color keeps the same color order even when flipped
    → the whole tower can be carried at once
  • For each color, build a BFS tree rooted at its nest
    • From the farthest cells, move the same-colored top part of the tower one cell toward the parent
    • The group grows like a snowball as paths merge
  • Number of moves ≈ number of edges in the union of paths (Steiner tree)
  • Slimes beyond height 8 are carried in the next round
pts

02bJump 2 cells using bases

  • While color c is being carried, slimes of other colors still stand alone at their initial cells
  • A group on top of one has k ≥ 1 → it can jump 2 cells
  • Build the tree by shortest number of moves, including "2 cells from a cell with a base"
  • Carry colors with fewer slimes first (bases remain longer)

So far, a human designs the procedure
→ we want to search for procedures that use bases and rides more freely

pts

03Ride-along insertion: add slimes one by one "afterward"

  • Fix the move sequence of the other slimes and add one slime x to it
  • Riding with the group of an existing jump moves x for 0 moves
  • A jump of x itself costs 1 move
    Using other slimes as bases, it can jump farther
  • Find the insertion with the fewest additional moves as a shortest path

03Seen in space-time

Before (x alone: 5 moves)
After (x: 3 moves)

Red: new jump of x (+1 move)

Green: ride on an existing jump (0 moves)

Gray: existing jumps

Vertical: time (moves). Horizontal: one row of the board.
x jumps 2 cells using the blues as bases, and finally jumps together with the blue group and goes home

03States and transitions

At move e (k, height h) at time t

  • Wait: e does not touch cell c 0 moves
  • Stay: z ≤ k → k of e increases by 1 0 moves
  • Jump together: z ≥ k → flipped, to z' = g + (h − z) at the landing cell 0 moves
  • A group lands on top: z unchanged 0 moves

If x is on top of the tower (z = h)

  • New jump: x alone jumps l ≤ h+1 1 move
  • The h slimes below serve as bases
  • It lands on top of the landing tower

Notes

  • Do not block homing: invalid if x (another color) ends up above slimes that should go home
  • Goal: x goes home when it is on top at its own nest
  • Height 8: a tower containing x is one slime taller than before

03Tips

Grouping by intervals makes it faster

  • A cell's tower does not change while moves not touching that cell continue → call such a time span an "interval"
  • For the same (cell, interval, z), keep only the earliest arrival (waiting within the interval reaches any later time)
  • New jump: x can jump at any time within its cell's interval, but the landing tower may change meanwhile
    • The state is determined by the landing cell's interval, so it suffices to try "now" and "right after the landing tower changes"

Merging same-colored runs (normalization)

  • Same-colored slimes are indistinguishable → wherever x is within a run of its color, the color order and everything afterward are the same
  • Represent the run by its top position as a single state
  • A transition is allowed if possible anywhere in the run: stay if the bottom ≤ k, jump together if the top ≥ k
  • Not only fewer states but more options: about 4% fewer moves (next page)

03Tips: examples where normalization helps

03Initial solution: insert in order of distance to the nest

  • Start from an empty move sequence and insert slimes one by one, closest to their nest first
    • Farther slimes can more easily ride on routes already decided
  • No need to design how to use bases and rides — the shortest path finds them automatically
  • Under 0.1 seconds per case
pts

04Hill climbing with ride-along insertion

Ride-along insertion can not only build a solution by adding slimes one by one, but also repair a solution after breaking part of it

Current moves
→
Remove one slime ykeep others' moves, shrink k
→
Reinsert yshortest path of 03
→
Accept if not more movesequal-move changes accepted too
  • Remove one random slime y
  • Choose randomly among equal-cost paths → more places to move to

Example: the red was inserted before the blues, so the blue tower was still low and it could jump only 3 cells. Later the tower grew to 4 blues → reinserting it jumps 5 cells straight home

04If y was a base

04Result of hill climbing

pts

05LNS (destroy and rebuild) + simulated annealing

  • Problem with 04: slimes of the same color move as a clump
    • Removing just one slime, it simply rejoins the same clump; the solution barely changes
    • About 60% of reinsertions return exactly the original move sequence
  • → Remove 1–6 slimes together and reinsert them one by one (LNS)
    • The number is random each time
    • From a random seed slime, pick by one of: nearby initial position / same color / jumping in consecutive moves
  • With several slimes, reinsertion often increases the moves → accept with simulated annealing
    • About 1% fewer moves than hill climbing

Tips: deciding the threshold first makes it faster

  • Decide the limit = current moves − temperature × log(random) before reinserting
  • The reinsertion 0-1 BFS can stop as soon as the moves exceed the limit
  • Same acceptance as ordinary simulated annealing

05Base reservation

  • When several slimes are removed, it is unclear who fills the missing bases
    • In 04 only y was removed, so y could fill it
  • → For each move that lacks bases, designate the slimes that fill them (base reservation)
  • A reserved slime is reinserted under the same constraint as y in 04

05Insertion with reservations

When removing: create reservations

  • Keep a move e as it is even if it now lacks bases
    • Shortage = number of missing bases for that jump, l − (k+1)
  • Designate reserving slimes, as many as the shortage
    • Among the removed slimes, those that were below the cut at e (from the top)
    • They were there originally, so they are likely to fit there again
  • Once it is decided that the reserving slime fills the shortage, it can be reinserted in the same way as in 04

When reinserting: keep the reservations

  • A slime x with a reservation must be below the cut at e's start cell at time e
    • It cannot wait at another cell across e, nor jump with e's group
    • It cannot go home before its last reservation
    • Add "how many reservations are done" to the state
  • If another slime fills the shortage below the cut instead, the reservation disappears
  • Reject if some reservation remains unfilled after reinserting everyone
pts

Refinements from 05 to the writer's solution

ElementIn a nutshellFewer moves
More ways to removeAlso pick by merge points, crossing paths, and slimes jumping together; prefer slimes that cost many moves0.9%
Order among equal costsPop the same-cost layer of the 0-1 BFS randomly / earliest first / latest first0.3%
Better implementationSpeedups, and building the initial solution several times2.8%
Same-color swapWhen removing, swap roles with a same-colored partner so no base shortage occurs0.2%
Held homingAnother color sits on a nest to stop homing, using the nest-colored slimes as temporary bases0.7%
Suffix re-planningFrom a mid-sequence board, re-carry same-colored clumps as single cargo for the rest of the sequence1.0%
Writer's solution: pts

How to remove, and which path to choose

More ways to remove (0.9%)

  • In addition to 05's "nearby / same color / consecutive moves"
    • Slimes jumping in moves that touch the same cell: rebuild the groups passing through a merge or split point together
    • Slimes jumping in moves whose paths cross
    • Partners jumping together from the same tower as the seed
  • With probability 1/2, the seed is a slime with a large burden
    • Burden = for each move, divide 1 move by the number of slimes jumping, and sum the shares
    • Prefer reworking slimes that tend to move alone and "cost many moves"

Order among equal costs (0.3%)

  • There are many shortest insertions, and which one is returned changes the next solution
    • Most accepted changes keep the number of moves
  • For each insertion, choose how to pop the same-cost layer of the 0-1 BFS
    • Random (2/3)
    • Earliest time first (1/6): favors paths that move early
    • Latest time first (1/6): favors paths that wait and then move
  • The tendencies of paths vary, widening where the solution can move

Better implementation and same-color swap

Better implementation (2.8%)

  • More iterations pay off directly: giving this editorial's implementation (first two rows) twice the time reduces moves by 1.8%
  • Speedups in the writer's solution
    • First check, with a dedicated fast test, whether a slime can be reinserted with no new jump (0 extra moves)
    • Reuse the search work areas and skip re-initialization
    • Pack tower colors 4 bits each into one integer
  • Build the initial solution several times with different insertion orders and start from the best

Same-color swap (0.2%)

  • When the removed slime y is below the cut and its color continues up past the cut
  • Swap roles between y and a same-colored partner in the jumping group, then remove
    • The color order does not change (same colors are indistinguishable)
    • y leaves as part of the jumping group, so no base shortage (reservation) is created

Held homing (0.7%)

Suffix re-planning (1.0%)

Score progression

Comparing the movements