Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopgrid · dynamic-programming · manhattan-distance
The organizer’s problem statement is available at the official source link.
grid path
Build a safe monotone path
A charm protects cells in a Manhattan-radius diamond; legal paths move only right or down and collect cell berries.
| S | path | . |
| path | charm | . |
| . | . | G |
- 1
Mark safe cells
Mark every cell covered by at least one charm’s Manhattan radius. - 2
Propagate best paths
Use a grid DP over safe cells, entering only from above or the left. - 3
Maximize berries
Carry the best berry total to the bottom-right destination.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.