This page is still under construction.

Parts of this page are still being built. What you see may change.

Lights (Small Input)

Time limit5sMemory limit512 MB

Summary
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 nn 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, TT.

Each test case consists of the following, in order.

  • One line with the coordinates x,yx, y of the red light source.
  • One line with the coordinates x,yx, y of the green light source.
  • One line with the number of pillars, nn.
  • nn lines describing the pillars, one per line. Each line holds three integers x,y,rx, y, r, and that pillar is the disk with center (x,y)(x, y) and radius rr.

The room is the square 0≤x,y≤1000 \le x, y \le 100. 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.
  • 1≤T≤151 \le T \le 15
  • 0≤x,y≤1000 \le x, y \le 100
  • 1≤r≤491 \le r \le 49
  • 0≤n≤10 \le n \le 1

Output

For each test case, first print Case #X:, where XX 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.

Examples3

  1. Example 1

    Input
    1
    5 50
    95 50
    1
    50 50 10
    
    Expected output
    Case #1:
    0.7656
    1437.9856
    1437.9856
    6809.1039
    
  2. Example 2

    Input
    1
    20 20
    80 80
    0
    
    Expected output
    Case #1:
    0.0000
    0.0000
    0.0000
    10000.0000
    
  3. Example 3

    Input
    1
    10 10
    90 20
    1
    40 60 15
    
    Expected output
    Case #1:
    195.3321
    1284.6484
    1553.0598
    6260.1013