*Light*Young*Woo*
Time limit1sMemory limit512 MB
Given N lights that each illuminate a 90-degree upward sector, count for each query point how many sectors contain it.
- Level
Medium5 of 10
- Topics
- Geometry, Prefix sum, Binary search, Sorting
- Solved
- No attempts yet
Problem
Let north be the direction. There are lights in the plane, with the -th light at .
Each light illuminates a -degree sector centered on north. A point receives light from the -th light exactly when
The boundary is included, so the point where a light stands is illuminated by that light. When several lights cover the same point, their intensities add up. That is, the intensity at equals the number of lights satisfying the condition above.
Input
The input is given from standard input. The first line contains the number of lights ().
The next lines each contain two integers (), the position of each light.
The next line contains the number of query points ().
The next lines each contain two integers (), the coordinates of each point whose intensity is asked.
Output
Print lines to standard output. The -th line contains the light intensity at .