CF44F.BerPaint

省选/NOI-

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

猴子安菲萨对文字处理器感到失望,因为它们无法充分表达她丰富的情感,因此她决定转而使用图形编辑器。打开 BerPaint 后,她看到一个尺寸为 W×HW \times H 的白色矩形画布,可在其上进行绘制。首先,安菲萨学会了使用绘图工具——该工具用于绘制线段,并迅速在该矩形上绘制了若干条黑色线段。但最终的图像在安菲萨看来仍不够鲜明,于是她将注意力转向了“填充”(fill)工具:该工具需在矩形内选定一个点并指定一种颜色,随后将所有与该点所在区域颜色相同的连通区域完全涂成所选颜色。安菲萨多次应用填充操作后,彻底表达了她的情感,随即停止了绘画。你的任务是:根据所绘制的线段信息以及所执行的填充操作,计算出每种颜色在全部填充操作完成后所占据的总面积。

输入格式

The first input line has two integers W and H (3 ≤ W, H ≤ 104) — 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 < _x_1, _x_2 < W, 0 < _y_1, _y_2 < 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 < x < W, 0 < y < 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.

第一行输入包含两个整数 WW 和 HH(3≤W,H≤1043 \leq W, H \leq 10^4)——表示初始为白色的矩形绘图区域的尺寸。
第二行输入包含一个整数 nn —— 黑色线段的数量(0≤n≤1000 \leq n \leq 100)。
接下来的 nn 行描述这些线段,每行由其两个端点的坐标 x1, y1, x2, y2x_1,\ y_1,\ x_2,\ y_2 给出(0<x1, x2<W0 < x_1,\ x_2 < W,0<y1, y2<H0 < y_1,\ y_2 < H)。所有线段长度均不为零。
下一行输入预设的填色操作次数 mm(0≤m≤1000 \leq m \leq 100)。
随后的 mm 行每行定义一次填色操作,格式为“x y colorx\ y\ \text{color}”,其中 (x, y)(x,\ y) 是所选点的坐标(0<x<W0 < x < W,0<y<H0 < y < H),color\text{color} 是一个由小写拉丁字母组成的字符串,长度为 11 至 1515 个字符,表示颜色。
输入中给出的所有坐标均为整数。
初始时,矩形区域为“白色”,而线段以“黑色”绘制。

输出格式

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.

对于最终图像中出现的每种颜色,在单独一行中输出该颜色的名称以及被涂成该颜色的区域总面积,精度为 10−610^{-6}。颜色的输出顺序任意。

输入输出样例

  • 输入#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.

最初,安菲萨绘制的黑色线段如果包含任意一个所选点,也可被涂上某种颜色。这些线段的面积为 0。因此,若最终图像中仅有线段的部分区域被涂上某种颜色,则该颜色所涂区域的面积仍为 0。

输入解题思路,AI测评打分。不知道怎么写?

首页