300221: CF44F. BerPaint

Memory Limit:256 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

BerPaint

题意翻译

在 $ W \times H $ 的白色平面中有 $n$ 条线段,以起止点坐标,即 ${x_1,y_1,x_2,y_2}$ 的形式输入。并对 $m$ 个点的所在封闭图形填色, **最后**以任意次序输出每种颜色的面积(包括未填充的白色)。 填充在黑色线段上的点面积为 $0$。 输出时保留小数点后 $8$ 位。

题目描述

Anfisa the monkey got disappointed in word processors as they aren't good enough at reflecting all the range of her emotions, that's why she decided to switch to graphics editors. Having opened the BerPaint, she saw a white rectangle $ W×H $ in size which can be painted on. First Anfisa learnt to navigate the drawing tool which is used to paint segments and quickly painted on that rectangle a certain number of black-colored segments. The resulting picture didn't seem bright enough to Anfisa, that's why she turned her attention to the "fill" tool which is used to find a point on the rectangle to paint and choose a color, after which all the area which is the same color as the point it contains, is completely painted the chosen color. Having applied the fill several times, Anfisa expressed her emotions completely and stopped painting. Your task is by the information on the painted segments and applied fills to find out for every color the total area of the areas painted this color after all the fills.

输入输出格式

输入格式


The first input line has two integers $ W $ and $ H $ ( $ 3<=W,H<=10^{4} $ ) — the sizes of the initially white rectangular painting area. The second line contains integer $ n $ — the number of black segments ( $ 0<=n<=100 $ ). On the next $ n $ lines are described the segments themselves, each of which is given by coordinates of their endpoints $ x_{1},y_{1},x_{2},y_{2} $ ( $ 0&lt;x_{1},x_{2}&lt;W,0&lt;y_{1},y_{2}&lt;H $ ). All segments have non-zero length. The next line contains preset number of fills $ m $ ( $ 0<=m<=100 $ ). Each of the following $ m $ lines defines the fill operation in the form of " $ x $ $ y $ $ color $ ", where $ (x,y) $ are the coordinates of the chosen point ( $ 0&lt;x&lt;W,0&lt;y&lt;H $ ), and $ color $ — a line of lowercase Latin letters from 1 to 15 symbols in length, determining the color. All coordinates given in the input are integers. Initially the rectangle is "white" in color, whereas the segments are drawn "black" in color.

输出格式


For every color present in the final picture print on the single line the name of the color and the total area of areas painted that color with an accuracy of $ 10^{-6} $ . Print the colors in any order.

输入输出样例

输入样例 #1

4 5
6
1 1 1 3
1 3 3 3
3 3 3 1
3 1 1 1
1 3 3 1
1 1 3 3
2
2 1 red
2 2 blue

输出样例 #1

blue 0.00000000
white 20.00000000

输入样例 #2

5 5
5
1 1 2 2
2 2 4 2
4 2 4 4
4 4 2 4
2 4 2 2
2
3 3 black
3 3 green

输出样例 #2

green 4.00000000
white 21.00000000

输入样例 #3

7 4
9
1 2 2 3
2 3 3 2
3 2 2 1
2 1 1 2
3 2 4 2
4 2 5 3
5 3 6 2
6 2 5 1
5 1 4 2
2
2 2 black
2 2 red

输出样例 #3

red 2.00000000
white 26.00000000

说明

Initially the black segments painted by Anfisa can also be painted a color if any of the chosen points lays on the segment. The segments have areas equal to 0. That is why if in the final picture only parts of segments is painted some color, then the area, painted the color is equal to 0.

Input

题意翻译

在 $ W \times H $ 的白色平面中有 $n$ 条线段,以起止点坐标,即 ${x_1,y_1,x_2,y_2}$ 的形式输入。并对 $m$ 个点的所在封闭图形填色, **最后**以任意次序输出每种颜色的面积(包括未填充的白色)。 填充在黑色线段上的点面积为 $0$。 输出时保留小数点后 $8$ 位。

加入题单

算法标签: