eolymp
bolt
Try our new interface for solving problems
Problems

Hide and seek

Hide and seek

In a playground, a group of kids is playing hide and seek. As the name suggests, the game is about kids hiding and seeking other kids. Each kid is either a hiding kid or a seeking kid. Hiding kids are kids that just try not to be found, while seeking kids are kids that try to find (hiding and seeking) kids. As you may note, both hiding and seeking kids try not to be found, and for doing this they use some walls that there are in the playground. Each wall is represented by a line segment and each kid is represented by a point in the \textbf{XY }plane. Two kids see each other if and only if the line segment between them does not intersect any wall segment. Your task is to calculate how many other kids each seeking kid can see. To simplify the problem, you may assume that walls do not intersect even at their endpoints. Moreover, no three points are collinear within the set formed by kids and endpoints of walls; this implies that kids are not inside walls, and that no two kids have the same location. \InputFile The first line contains three integers \textbf{S}, \textbf{K} and \textbf{W} representing respectively the number of seeking kids, the total number of kids and the number of walls in the playground (\textbf{1} ≤ \textbf{S} ≤ \textbf{10}, \textbf{1} ≤ \textbf{K}, \textbf{W} ≤ \textbf{10_4} and \textbf{S} ≤ \textbf{K}). Each of the next\textbf{K} lines describes a kid with two integers \textbf{X} and \textbf{Y} (\textbf{-10^6} ≤ \textbf{X}, \textbf{Y} ≤ \textbf{10^6}), indicating that the location of the kid in the\textbf{XY} plane is the point (\textbf{X}, \textbf{Y}); the first \textbf{S} of these lines describe seeking kids. Each of the next \textbf{W} lines describes a wall with four integers \textbf{X_1}, \textbf{Y_1}, \textbf{X_2} and \textbf{Y_2} (\textbf{-10^6} ≤ \textbf{X_1}, \textbf{Y_1}, \textbf{X_2}, \textbf{Y_2} ≤ \textbf{10^6}), indicating that the two endpoints of the wall in the \textbf{XY} plane are (\textbf{X_1}, \textbf{Y_1}) and (\textbf{X_2}, \textbf{Y_2}). You may assume that wall segments do not intersect and no three points given in the input are collinear. \OutputFile Output \textbf{S} lines, each of them containing an integer. In the \textbf{i}-th line write the number of other kids the \textbf{i}-th seeking kid can see.
Time limit 1 second
Memory limit 64 MiB
Input example #1
5 6 4
40 40
60 10
70 30
60 80
30 81
20 40
0 10 40 50
10 61 30 61
-100 90 200 90
50 20 50 50
Output example #1
1
2
3
5
2
Author Pablo Ariel Heiber
Source ACM ICPC Regional Latino America 2013