WC '15 Contest 2 J3 - Return of the Jedi

View as PDF

Submit solution


Points: 5
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
Woburn Challenge 2015-16 Round 2 - Junior Division
"Coding? What do you mean, you're coding? Coding what, Artoo? No, wait! Artoo! This is no time for heroics!"

Things are coming to a head on the forest moon of Endor. E (1 \le E \le 100) 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 i-th Ewok located at integer coordinates (X_{e_i}, Y_{e_i}) (0 \le X_{e_i}, Y_{e_i} \le 1\,000).

Unfortunately, the Empire seems to be onto the rebels' plan! S (1 \le S \le 100) stormtroopers have similarly been dispatched into the woods to guard the perimeter, with the i-th one stationed at coordinates (X_{s_i}, Y_{s_i}) (0 \le X_{s_i}, Y_{s_i} \le 1\,000). Each stormtrooper is also classified as one of four types, depending on the weaponry they carry. Namely, the i-th stormtrooper is of type W_i (1 \le W_i \le 4). 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:

  1. The E-11 blaster rifle – a powerful and compact weapon that is the most widely used in the galaxy.
  2. The E-11b blaster rifle – an expert version of the standard E-11 with expensive cooling units.
  3. The E-11s sniper blaster rifle – a modified blaster for long-range use by imperial scout troopers.
  4. 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 R (1 \le R \le 10\,000) 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 R units away.

As a reminder, if the absolute difference between the x-coordinates of two points is x, and the absolute difference between their y-coordinates is y, then the (Euclidean) distance between them is \sqrt{x^2 + y^2}.

How many of the E Ewoks are in danger?

Input Specification

The first line of input consists of three space-separated integers S, E, and R.
The next S lines each consist of three space-separated integers W_i, X_{s_i} and Y_{s_i}, for i = 1 \dots S.
The next E lines each consist of two space-separated integers X_{e_i} and Y_{e_i}, for i = 1 \dots E.
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 2nd Ewok is in danger due to being only 2 units away from the 1st stormtrooper (type 1) and 4 units away from the 3rd stormtrooper (type 2).
The 4th and 5th Ewoks are also in danger, as they are within range of the 1st stormtrooper (type 1) and 4th stormtrooper (type 3).
The remaining three Ewoks are safe.


Comments

There are no comments at the moment.