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 x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
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.
5 1 2 5 5 2
5 AAAAA BBBBB BBBBB CCCCC CCCCC
4 4 2 6 4 2
6 BBBBBB BBBBBB AAAACC AAAACC AAAACC AAAACC 题意很清楚. 给三个矩形,问能否拼成一个正方形. 我们先把矩形都躺着放(保证x<=y) 然后容易知道,一共有两种可能的方法 一种是三个矩形罗在一起 另外一种是一个矩形在上面,下面两个矩形竖着放. 后一种方法又因为上面的矩形的不同以及下面两个矩形的横竖放置不同(00 01 10 11)*3 所以一共有12种要枚举... 直接写会累死... 想了个简单点的办法,具体见代码. 一遍AC,好爽!!!
1 /************************************************************************* 2 > File Name: code/cf/#322/D.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年09月30日 星期三 17时21分24秒 6 ************************************************************************/ 7 #include8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include