Lights (Small Input)
Time limit5sMemory limit512 MB
For one pillar at most, compute the areas lit by red only, green only, both, and neither within a 100 by 100 square.
- Level
Medium5 of 10
- Topics
- Geometry, Implementation
- Solved
- No attempts yet
Problem
A large square room holds two point light sources, one red and one green. The room also contains circular pillars.
Light travels in straight lines and is absorbed by the walls and by the pillars. A pillar lets no light through, so it casts a shadow. Some places in the room get no light at all (black), some get light from the red source only (red), some get light from the green source only (green), and some get light from both sources (yellow). Compute the total area of each of the four colors. The part covered by the pillars counts toward none of those areas.
Input
The first line contains the number of test cases, .
Each test case consists of the following, in order.
- One line with the coordinates of the red light source.
- One line with the coordinates of the green light source.
- One line with the number of pillars, .
- lines describing the pillars, one per line. Each line holds three integers , and that pillar is the disk with center and radius .
The room is the square . The pillars, the room walls and the two light sources are pairwise disjoint: none of them overlap or touch.
Limits
- Every number in the input is an integer.
Output
For each test case, first print Case #X:, where is the test case number starting from 1. Then print four lines holding the black area, the red area, the green area and the yellow area, in that order.
Case #X:
black area
red area
green area
yellow area
Round each area to exactly four digits after the decimal point. An area of zero is printed as 0.0000.