#K39672. Overlapping Coordinates

    ID: 26473 Type: Default 1000ms 256MiB

Overlapping Coordinates

Overlapping Coordinates

You are given the movement coordinates of two species, Species A and Species B, within a rectangular reserve. The reserve has a width \(W\) and a height \(H\). The coordinates for each species are recorded as integer pairs \((x, y)\). Your task is to determine the number of unique overlapping coordinates between the two species. An overlapping coordinate is a point that appears in both species' movement records.

The input begins with four integers:\nbsp; \(Na, Nb, W, H\), where \(Na\) and \(Nb\) are the number of recorded coordinates for Species A and Species B respectively. This is followed by \(Na\) lines each containing a coordinate for Species A, and then \(Nb\) lines each containing a coordinate for Species B.

Example:
If the input is:

4 3 20 20
10 15
15 10
5 5
10 10
15 10
10 15
5 5

Then the output should be:

3

This indicates that there are 3 unique overlapping points between the two species.

inputFormat

The input is given via stdin and has the following format:

  • The first line contains four space-separated integers: \(Na\), \(Nb\), \(W\), \(H\). \(Na\) and \(Nb\) represent the number of coordinates for Species A and Species B, respectively. \(W\) and \(H\) are the width and height of the reserve.
  • The next \(Na\) lines each contain two space-separated integers representing a coordinate \((x, y)\) for Species A.
  • The following \(Nb\) lines each contain two space-separated integers representing a coordinate \((x, y)\) for Species B.

outputFormat

The output, printed to stdout, is a single integer indicating the number of unique overlapping coordinates between the two species.

## sample
3 3 10 10
1 1
2 2
3 3
4 4
5 5
6 6
0

</p>