Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2017 /round1 /fightingthezombies.md
wjomlex's picture
2017 Problems
7acee6b verified
In the ever-popular role-playing game _Dungeons & Dragons_, or _D&D_, some
wizards enhance their skills by training as geometers, specialist spellcasters
who rely on the inherent magical properties of geometric forms.
Unlike low-level wizards who may be able to fight only a single zombie at a
time, you, the budding geometer, are ready and able to fight medium-sized
hordes!
There are **N** zombies on an infinite 2D plane, with the _i_th one at
coordinates (**Xi**, **Yi**). You have two spells at your disposal, but you
can only cast each one once.
You'll first cast the function-spell `Move(x, y, r, dx, dy)`. Each of its five
parameters can be any real number, though `r` must be positive. Upon
performing this spell, each zombie initially within the circle centered at
coordinates (`x`, `y`) and having radius `r` will have its coordinates
translated by (`dx`, `dy`). In other words, it will have `dx` added to its
x-coordinate, and `dy` added to its y-coordinate. Zombies on the border of the
circle are also affected.
You'll then cast the function-spell `Destroy(x, y)`. Each of its two
parameters can be any real number. Upon performing this spell, each zombie
currently within the axis-aligned square centered at coordinates (`x`, `y`)
and having side-length **R** will be destroyed. Zombies on the border of the
square are also affected.
![]({{PHOTO_ID:336634350719298}}) ![]({{PHOTO_ID:268425761045248}})
What's the largest number of zombies that can be destroyed by this combination
of function-spells?
### Input
Input begins with an integer **T**, the number of zombie hordes you fight. For
each case, there is first a line containing two space-separated integers,
**N** and **R**. Then, **N** lines follow, the _i_th of which contains 2
space-separated integers, **Xi** and **Yi**.
### Output
For the _i_th case, print a line containing "Case #**i**: " followed by the
maximum number of zombies you can slay with your spells.
### Constraints
1 ≤ **T** ≤ 50
1 ≤ **N** ≤ 50
0 ≤ **Xi**, **Yi** ≤ 1,000,000,000
1 ≤ **R** ≤ 1,000,000,000
It is guaranteed that no two zombies are initially at the same point, though
zombies may later be moved such that there are multiple at the same
coordinates.
### Explanation of Sample
In the first case (shown in the pictures above), one optimal strategy is to
first cast `Move(2.5, 4.5, 2.2, 3, -1)`, moving 4 zombies, and then cast
`Destroy(5.5, 2.5)`, destroying 6 zombies.