Zombie Smash (Small)
Time limit5sMemory limit512 MB
Plan a route from (0, 0) that smashes the most zombies, each catchable for 1000 ms after it appears, with 8-direction moves and a 750 ms smasher recharge.
- Level
Medium5 of 10
- Topics
- Brute force, Intervals, Geometry
- Solved
- No attempts yet
Problem
Zombie Smash is a game where you smash zombies with your Zombie Smasher as they pop out of graves in a graveyard. The graveyard is a flat 2D grid. Each zombie pops out of a grave at some cell , stands in place for 1000 milliseconds, then drops back into the grave. At most one zombie stands at a grave at a time.
You move to any one of the 8 cells adjacent to your own in 100 milliseconds, so you can step north, east, south, west, northwest, northeast, southwest, or southeast. You may walk through or stand on a cell that a zombie occupies. You smash a zombie the instant you reach the cell it stands on, but after a smash the Zombie Smasher takes 750 milliseconds to recharge, and during that time you cannot smash the next zombie. You are free to keep moving while it recharges. For example, right after smashing a zombie at :
- reaching and smashing a zombie at takes 750 milliseconds,
- reaching and smashing a zombie at takes 2000 milliseconds.
At time , when the game starts, you stand at cell with a fully charged smasher. After a level ends, work out how many zombies you could have smashed with optimal play.
Input
The first line contains a single integer , the number of test cases. Each test case starts with a line containing a single integer , the number of zombies in the level.
The next lines each contain three space-separated integers , and , giving the location and the time at which one zombie appears.
- is the coordinate of the cell where zombie appears.
- is the coordinate of the cell where zombie appears.
- is the time at which zombie appears, in milliseconds after the start of the game. The interval in which a zombie can be smashed is inclusive: if you reach its cell at any time in with a charged Zombie Smasher, you smash that zombie.
Limits
- Two zombies are never in the same location at the same time. If one zombie appears at at time , then any other zombie appearing at appears at or before , or at or after .
Output
For each test case, print one line in the form Case #c: d, where is the test case number starting from 1 and is the largest number of zombies you could have smashed in that level.