Electrical Engineering
Time limit1sMemory limit128 MB
For each query point, find the strongest signal among routers whose segment to the point crosses no polygon wall, using 1/d^2 falloff.
- Level
Medium5 of 10
- Topics
- Geometry, Brute force, Implementation, Math
- Solved
- No attempts yet
Problem
Electrical engineers study how electrical and electronic devices are built and how they communicate with one another. A popular topic is wireless networking. Here we look at a simplified model of providing wireless coverage to an area.
The area is a polygon given by a sequence of corners, and every edge of the polygon acts as a wall. Inside (or around) the area there are one or more wireless routers. Signal strength is modeled as follows.
- If a wall lies on the straight segment between a router and a location, that router gives the location no signal at all (strength ).
- If there is no wall, the signal strength from that router is , where is the distance between the router and the location.
- If a location receives a signal from several routers, only the strongest signal is counted.
For several query locations, report the resulting signal strength.
This model ignores reflection of signals off walls and penetration through walls.
Input
The first line contains an integer , the number of data sets. Each data set has the following form.
The first line of a data set contains three integers , , : the number of polygon corners, the number of routers, and the number of query points. All three values are between and .
- The next lines each contain a corner as two floating-point numbers , listed in order around the polygon.
- The next lines each contain a router location .
- The final lines each contain a query point .
You may assume that (1) no router or query point lies exactly on a wall, (2) no router coincides with a query point, and (3) the segment from a router to a query point never merely touches a wall — it either properly crosses the wall or avoids it completely.
Output
For each data set, first print Data Set x: on a line by itself, where is the data set number, starting from . Then, for each of the query points, print on a line by itself the maximum signal strength at that point, rounded to two decimal places.