Wireless
InterviewTime limit1sMemory limit128 MB
Given K circles with integer centers and integer radii on a grid of intersections, compute the maximum total bitrate sum any intersection receives and how many intersections achieve it.
- Level
Medium7 of 10
- Topics
- Geometry, Implementation, Brute force, Sorting
- Solved
- No attempts yet
Problem
Bob is sitting at home with his computer. He would like to experience more social interaction, so he is planning a trip to a coffee shop with his computer.
In Bob's city there is one coffee shop at every intersection of streets. The city has streets that run east and west () and streets that run north and south (). The distance between consecutive parallel streets is exactly 1 metre (it is a very compact city).
Inside of the coffee shops () there is a wireless network station. Each station has a bitrate () and can reach up to metres () from its coffee shop. In other words, a station covers a circle of radius centred at its coffee shop. Someone exactly at distance can use the network, but someone at a distance greater than cannot.
Each coffee shop holds at most one wireless station, yet several networks may be usable from a single coffee shop when stations at nearby shops reach it.
Bob's computer has a special device that can combine and use the bitrates of every wireless network it can connect to.
Bob would like to know the maximum bitrate he can obtain and how many coffee shops offer that maximum.
Input
The first line contains the integer , the number of east-west streets. The second line contains the integer , the number of north-south streets. The third line contains the integer , the number of coffee shops that have a wireless network. Each of the next lines contains four integers. The first integer is the north-south street the coffee shop is on, with . The second integer is the east-west street the coffee shop is on, with . The third integer is the radius of that coffee shop's wireless network. The fourth integer is the bitrate of that coffee shop's wireless network.
Output
The output is two lines. The first line is the integer giving the maximum bitrate obtainable over all coffee shops (intersections). The second line is the number of coffee shops at which this maximum bitrate can be obtained.
Hint
In the figure below, the five coffee shops (intersections) marked with a dark circle all have total bitrates of 12.
