QOJ.ac

QOJ

Time Limit: 3 s - 15 s Memory Limit: 1024 MB Total points: 66

#5813. Lights

统计

Problem

In a big, square room there are two point light sources: one is red and the other is green. There are also n circular pillars.

Light travels in straight lines and is absorbed by walls and pillars. The pillars therefore cast shadows: they do not let light through. There are places in the room where no light reaches (black), where only one of the two light sources reaches (red or green), and places where both lights reach (yellow). Compute the total area of each of the four colors in the room. Do not include the area of the pillars.

Input

  • One line containing the number of test cases, T.

Each test case contains, in order:

  • One line containing the coordinates x, y of the red light source.
  • One line containing the coordinates x, y of the green light source.
  • One line containing the number of pillars n.
  • n lines describing the pillars. Each contains 3 numbers x, y, r. The pillar is a disk with the center (x, y) and radius r.

The room is the square described by 0 ≤ x, y ≤ 100. Pillars, room walls and light sources are all disjoint, they do not overlap or touch.

Output

For each test case, output:

Case #X:
black area
red area
green area
yellow area

where X is the test case number, starting from 1, and each area is a real number.

Any answer with absolute or relative error of at most 10-5 will be accepted.

Limits

Memory limit: 1 GB. All input numbers are integers.

1 ≤ T ≤ 15

0 ≤ x, y ≤ 100

1 ≤ r ≤ 49

Small dataset (21 Points)

Time limit: 20 3 seconds.

0 ≤ n ≤ 1

Large dataset (45 Points)

Time limit: 90 15 seconds.

0 ≤ n ≤ 50

Sample

1
5 50
95 50
1
50 50 10
Case #1:
0.7656121
1437.986
1437.986
6809.104
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.