Foreclosure Borough
Time limit1sMemory limit128 MB
For each polygon borough, compute the percentage of houses inside it that are in foreclosure, sort boroughs by rate, and print two-decimal rates with tie-breaking by borough number.
- Level
Medium5 of 10
- Topics
- Geometry, Sorting, Implementation
- Solved
- No attempts yet
Problem
You are given the locations of houses and, for each house, whether it is currently in foreclosure. You are also given several boroughs (areas), each described by a simple (non-self-intersecting) polygon. Different boroughs may overlap, so a single house can belong to more than one borough.
For every borough, compute its foreclosure rate: the percentage of the houses located inside that borough that are in foreclosure. Then report the boroughs sorted by this rate.
Input
The first line contains the number of data sets . Each data set has the following form:
- The first line contains two integers and : the number of houses () and the number of boroughs ().
- Each of the next lines describes one house: its and coordinates (floating-point numbers) followed by a single character,
Yif the house is in foreclosure orNif it is not. - Each of the next lines describes one borough. The line begins with an integer , the number of polygon corners, followed by floating-point numbers giving the corners in counter-clockwise order.
No house lies exactly on the boundary of a borough, and every borough contains at least one house.
Output
For each data set, first print a line Data Set x:, where is the 1-based index of the data set. Then print one line for each of the boroughs.
Each borough line has the form b: r%, where is the borough number (its 1-based position in the input) and is its foreclosure rate as a percentage, rounded to exactly two decimal places (round half up).
Sort the borough lines by non-increasing foreclosure rate; break ties by the smaller borough number. Print an empty line between consecutive data sets.