F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Paint the Wall

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1514    Accepted Submission(s): 521


Problem Description
Here comes our future artist. See, he is painting again, this time on home's white wall, using different color of paint. Let me see, red, yellow, black, green... but why does he just paint rectangles? Pretty guy, seems he is fond of it.

So, after he's done his great job, the white wall has been filled with so many blocks of color. Of course, some color previously painted has been covered by some color painted later. Now, the little guy has some doubt that how many different colors have been left on the wall, and what are the areas of them. As a seven-year-old boy, he has just learned painting in kindergarten, math seems too difficult for him. So he turns to you, a college student good at math and programming, to help him figuring it out. Don't make him disappointed.
 

Input
Input consists of multiple test cases, each describing "a great job" done by out little guy.

Each case begins with a line containing two integers, Height and Width, the size of the wall. The next line contains an integer N, which is the number of rectangles that have been painted. N lines follow, describing the rectangles in the order they were painted. Each line contains five integers, Top, Left, Bottom, Right, and Color, giving out the position, size and color information of the rectangle.

The range of Height and Width is [1, 10000]. There will be at least 1, and at most 100 rectangles to be painted. For each rectangle, Top and Bottom is in the range [0, Height], Left and Right is in the range [0, Width]. Bottom is strictly greater than Top, and Right is strictly greater than Left. Color will be in the range [1, 100].

The top-left coordinate of the wall is (0, 0), and the bottom-right coordinate of the wall is (Height, Width), as shown below.


(0,0) (0,W)
---------------
| |
| |
| |
| |
| |
---------------
(H,0) (H,W)



The last case is followed by a line containing two zeroes.

There is a blank line between two test cases.
 

Output
For each painting, first output "Case X:" in a single line where X is the case number starting form 1. Then output the colors left and their areas, one color per line, in the order of color numbers (increasing). For each color, you should output the color number, a blank space, and the area of this color on the wall. After that, you should output a single line "There is M color left on the wall." or "There are M colors left on the wall.", depending on M, which is the number of colors left on the wall.

Output a blank line between two test cases.
 

Sample Input
10 5 1 1 1 2 2 2 4 4 2 0 0 3 3 1 2 2 4 4 2 0 0
 

Sample Output
Case 1: 2 1 There is 1 color left on the wall. Case 2: 1 8 2 4 There are 2 colors left on the wall.
 

Author
DAI, Wenbin
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-25 02:15:12, Gzip enabled