Exhausted Robot

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 4785
64-bit integer IO format: %I64d      Java class name: Main

Description

  You want a tidy palace but you are too lazy to do the cleaning. As a result, your cousin Coach Pang gave you a cleaning robot. Unfortunately, the robot has some flaws and some furniture may hamper the cleaning.
  To simplify the problem, we consider all objects in a 2D-Plane. The room is viewed as a rectangle with edges parallel to the axis. Both robot and furniture are in shape of convex polygons.
  During the cleaning, the robot can move towards any direction (but only translation are permitted which means it cannot rotate). Although the robot has the ability to move through furniture, it can only do cleaning when it has no area outside the room or intersect with furniture. Besides, only one point can do the cleaning which is given as the first vertex of the robot in the input.

Input

  The first line of the input contains an integer T indicates the number of test cases.
  In the first line of each test case, there will be an integer n (0 <= n <= 20) and then (n + 1) blocks of data describing the objects. The first n blocks for furniture and the last one for the robot. All the vertices of an object are shown in corresponding block with counter-clockwise order. The first line of each block contains an integer m (3 <= m <= 20). Then m lines follow. In each line, there are two integers xi, yi indicating a vertex of the convex polygon.
闍t the end of each set of data, there will be four integers in a line, xBL, yBL, xTR, yTR, indicates the coordinates of the bottom left corner and the top right corner of your room.
闠he absolute value of all coordinates are within 103.

Output

  For each test case, output one line “Case #x: y”, where x is the case number (starting from 1) and y is size of the area that robot can clean, rounded to 3 digits after decimal point.

Sample Input

2
1
4
3 3
4 3
4 4
3 4
4
1 1
2 1
2 2
1 2
0 0 10 10
0
4
1 1
2 1
2 2
1 2
0 0 10 10

Sample Output

Case #1: 77.000
Case #2: 81.000

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .