Hide and seek
Time limit5sMemory limit128 MB
Count, for each of up to 10 seekers, how many of 10,000 kids are visible when 10,000 disjoint wall segments block sight lines.
Problem
A group of kids is playing hide and seek in a playground. Each kid is either a hiding kid or a seeking kid. A hiding kid only tries not to be found, while a seeking kid tries to find other kids, both the hiding ones and the seeking ones.
Hiding kids and seeking kids alike would rather not be found, so they keep the walls of the playground between themselves and everyone else. Each wall is a line segment and each kid is a point in the plane. Two kids see each other exactly when the segment joining them crosses no wall segment.
For every seeking kid, count how many other kids that kid can see. To keep the problem simple, assume two things. No two walls meet, not even at their endpoints. And no three points are collinear in the set of all kid positions together with all wall endpoints, so no kid stands on a wall and no two kids share a position.
Input
The first line contains three integers , and : the number of seeking kids, the total number of kids, and the number of walls in the playground (, , ).
Each of the next lines contains two integers and (), meaning that this kid stands at the point of the plane. The first of these lines describe the seeking kids.
Each of the next lines contains four integers , , and (), meaning that this wall has endpoints and . Wall segments never intersect, and no three of the given points are collinear.
Output
Print lines. On the -th line print the number of other kids that the -th seeking kid can see.