← CSES Better

Save Spaceman Spiff

ZCO · 2013 · Zonal Computing Olympiad · ZCO13004

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

grid · dynamic-programming · simulation

The organizer’s problem statement is available at the official source link.

time grid

Treat time as part of each grid state

Find the least time to reach the ship while moving right/down and avoiding blasters, their cells, and time-dependent pulses.

Problem grid; highlighted cells show the illustrated path
(r,c,t)->(r,c+1,t+1)
||
(r+1,c,t+1)->next state
  1. 1

    Track time and position

    A legal move advances one second; blaster pulses move one cell per second and fire periodically.
  2. 2

    Reject collisions

    A move is unsafe if Spaceman and a pulse share a cell at the same time, or the destination is a blaster cell.
  3. 3

    Minimize arrival time

    Search the time-expanded grid for the earliest safe arrival at the ship.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 chars

Run output

Run your code to see output.