CF581D.Three Logos
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
三家公司在一块广告牌上展示各自公司的徽标。广告牌是一块大型正方形板。每家公司的徽标均为一个面积非零的矩形。
广告商仅当能够将三个徽标全部放置在广告牌上、且彼此不重叠、同时广告牌上不留任何空余空间时,才会投放该广告。放置徽标时,必须将其旋转,使得徽标的边与广告牌的边平行。
你的任务是判断:是否存在某个正方形广告牌,使得三家公司的徽标均能按上述规则放置其上。
输入格式
The first line of the input contains six positive integers _x_1, _y_1, _x_2, _y_2, _x_3, _y_3 (1 ≤ _x_1, _y_1, _x_2, _y_2, _x_3, _y_3 ≤ 100), where x__i and y__i determine the length and width of the logo of the i-th company respectively.
输入的第一行包含六个正整数 x1, y1, x2, y2, x3, y3(1≤x1, y1, x2, y2, x3, y3≤100),其中 xi 和 yi 分别表示第 i 家公司的徽标长度和宽度。
输出格式
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
- the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
- the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
- the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
如果无法将三个徽标全部放置在一个正方形盾牌上,则输出单个整数 -1(不带引号)。
如果可以放置,则在第一行输出正方形边长 n,使得所有三个徽标均可被放置于该正方形中。接下来的 n 行中,每行应包含 n 个大写英文字母 "A"、"B" 或 "C"。相同字母组成的集合必须构成实心矩形,且满足:
- 由字母
"A"构成的矩形尺寸必须等于第一家公司的徽标尺寸, - 由字母
"B"构成的矩形尺寸必须等于第二家公司的徽标尺寸, - 由字母
"C"构成的矩形尺寸必须等于第三家公司的徽标尺寸,
注意:公司徽标在印制到广告牌上时可以旋转。广告牌不得留有任何空白区域。若存在多种方式用徽标填满一个正方形广告牌,输出其中任意一种即可。
请参阅样例以更清晰地理解题意。
输入输出样例
输入#1
5 1 2 5 5 2
输出#1
5 AAAAA BBBBB BBBBB CCCCC CCCCC
输入#2
4 4 2 6 4 2
输出#2
6 BBBBBB BBBBBB AAAACC AAAACC AAAACC AAAACC
输入解题思路,AI测评打分。不知道怎么写?