#P6432. [USACO3.1] 形成的区域 Shaping Regions
[USACO3.1] 形成的区域 Shaping Regions
Description
opaque rectangles of different colors are placed on a sheet of white paper with width and height . Their edges are parallel to the edges of the paper, and all rectangles are placed inside the paper.
Now they are overlapped. After overlapping, various colored regions of different shapes will appear. You need to find the area of each color.
The coordinates of the lower-left corner of the paper are the origin , and the coordinate axes are parallel to the edges of the paper.
Input Format
The input has a total of lines.
The first line contains three integers .
Lines to each contain five integers , representing the coordinates of the lower-left corner and upper-right corner of a rectangle, and its color index. Note: Color is the same as the color of the bottom white paper.
Output Format
Output a summary of every visible color and its total area. Each line should contain the color index and the area. Even if the regions of a color are not connected, you should still output the total area. Output the results in increasing order of , and do not output colors with zero visible area.
20 20 3
2 2 18 18 2
0 8 19 19 3
8 0 10 19 4
1 91
2 84
3 187
4 38
Hint
Explanation for Sample Input/Output 1
After all layers have covered the paper, the areas of the colors are , respectively.
Constraints
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号