Woburn Challenge 2015-16 Round 2 - Junior Division

Things are coming to a head on the forest moon of Endor.
friendly Ewoks have been sent out to scout the area, in
preparation for an attack on the shield generator protecting the
Empire's devastating weapon – the Death Star. From a bird's eye view,
the forest can be modelled as a Cartesian plane, with the
-th Ewok
located at integer coordinates
.
Unfortunately, the Empire seems to be onto the rebels' plan!
stormtroopers have similarly been dispatched into the woods
to guard the perimeter, with the
-th one stationed at coordinates
. Each
stormtrooper is also classified as one of four types, depending on the
weaponry they carry. Namely, the
-th stormtrooper is of type
. The BlasTech E-11 rifles may be the standard weapon
of these imperial stormtroopers, but most don't know that there are
variants of the E-series weapons which serve different purposes and
possess different strengths for attacking an opponent. The variants are:
- The E-11 blaster rifle – a powerful and compact weapon that is the most widely used in the galaxy.
- The E-11b blaster rifle – an expert version of the standard E-11 with expensive cooling units.
- The E-11s sniper blaster rifle – a modified blaster for long-range use by imperial scout troopers.
- The E-15 "Vindicator" sniper blaster rifle – a heavy-power weapon with a short design, making it greatly feared throughout the galaxy.
Each stormtrooper can hit targets that are located up to a distance of
units away with deadly accuracy. Ewoks are
quick enough to handle any number of a single type of stormtrooper using
their nifty spears and slingshots. However, any more than a single type
of stormtrooper poses a risk to them, since varying types of blasters
are much more difficult to handle. In other words, any given Ewok is in
danger if there are two or more types of stormtroopers which are no
more than
units away.
As a reminder, if the absolute difference between the -coordinates of
two points is
, and the absolute difference between their
-coordinates is
, then the (Euclidean) distance between them is
.
How many of the Ewoks are in danger?
Input Specification
The first line of input consists of three space-separated integers ,
, and
.
The next lines each consist of three space-separated integers
,
and
, for
.
The next lines each consist of two space-separated integers
and
, for
.
All pairs of coordinates in the input are distinct — i.e. no two
individuals (Ewoks or stormtroopers) are at the same location.
Output Specification
Output a single integer – the number of Ewoks that are in danger.
Sample Input
4 6 5
1 10 10
1 11 9
2 16 10
3 11 10
1 1
12 10
22 10
7 12
10 6
13 15
Sample Output
3
Explanation
There are four stormtroopers with the first two carrying an E-11, the
third carrying an E-11b, and the fourth carrying an E-11s.
The nd Ewok is in danger due to being only
units away from the
st
stormtrooper (type
) and
units away from the
rd stormtrooper (type
).
The th and
th Ewoks are also in danger, as they are within range of
the
st stormtrooper (type
) and
th stormtrooper (type
).
The remaining three Ewoks are safe.
Comments