IOI '03 - Kenosha, Wisconsin, USA
Farmer Don watches the fence that surrounds his
Fence posts appear at all four corners and also at every meter along
each side of the fence, for a total of
Farmer Don's field contains
Given the size of Farmer Don's fence, the locations and shapes of the rocks within it, and the location where Farmer Don stands, compute the number of fence posts that Farmer Don can see. If a vertex of a rock lines up perfectly with a fence post from Farmer Don's location, he is not able to see that fence post.
Input Specification
The first line of input contains two space-separated integers:
- The next line of input contains two space-separated integers that
specify the
and coordinates of Farmer Don's location inside the fence. - The rest of the input file describes the
rocks:- Rock
's description starts with a line containing a single integer , the number of vertices in a rock's base. - Each of the next
lines contains a space-separated pair of integers that are the and coordinates of a vertex. The vertices of a rock's base are distinct and given in counterclockwise order.
- Rock
Output Specification
The output file should contain a single line with a single integer, the number of fence posts visible to Farmer Don.
Sample Input
100 1
60 50
5
70 40
75 40
80 40
80 50
70 60
Sample Output
319
Comments