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.

Input

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.

Output

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.

Examples
Input

Copy
5 1 2 5 5 2
Output

Copy
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input

Copy
4 4 2 6 4 2
Output

Copy
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
暴力就完事了;
代码应该是看不下去的;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 1000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int h[4], w[4];
char mp[300][300];
char ch[3] = { 'A','B','C' };
int main() {
//ios::sync_with_stdio(0);
for (int i = 1; i <= 3; i++) {
cin >> h[i] >> w[i]; if (h[i] > w[i])swap(h[i], w[i]);
}
if ((w[1] == w[2]&&w[2] == w[3]) && h[1] + h[2] + h[3] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = h[1] + 1; j <= h[2] + h[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[1] + h[2]; j <= w[1]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
else {
int pos = 0;
int maxx = 0;
for (int i = 1; i <= 3; i++) {
if (w[i] > maxx) {
maxx = w[i]; pos = i;
}
}
if (pos == 1) {
if (h[2] + h[3] == w[1]) {
if (w[3] == w[2] && w[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= h[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + h[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (h[2] + w[3] == w[1]) {
if (w[2] == h[3] && w[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= h[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + h[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (w[2] + h[3] == w[1]) {
if (h[2] == w[3] && h[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + w[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (w[2] + w[3] == w[1]) {
if (h[2] == h[3] && h[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + w[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
} else if (pos == 2) {
if (h[1] + h[3] == w[2]) {
if (w[3] == w[1] && w[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (h[1] + w[3] == w[2]) {
if (h[3] == w[1] && w[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + h[3] == w[2]) {
if (w[3] == h[1] && h[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + w[3] == w[2]) {
if (h[3] == h[1] && h[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
}
else {
if (h[1] + h[2] == w[3]) {
if (w[2] == w[1] && w[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (h[1] + w[2] == w[3]) {
if (h[2] == w[1] && w[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + h[2] == w[3]) {
if (w[2] == h[1] && h[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + w[2] == w[3]) {
if (h[2] == h[1] && h[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
} }
cout << -1 << endl;
return 0;
}

CF581D Three Logos 暴力的更多相关文章

  1. cf581D Three Logos

    Three companies decided to order a billboard with pictures of their logos. A billboard is a big squa ...

  2. Codeforces Round #322 (Div. 2) D. Three Logos 暴力

    D. Three Logos Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/problem ...

  3. hdu2328 Corporate Identity【string库使用】【暴力】【KMP】

    Corporate Identity Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  4. (KMP 暴力)Corporate Identity -- hdu -- 2328

    http://acm.hdu.edu.cn/showproblem.php?pid=2328 Corporate Identity Time Limit: 9000/3000 MS (Java/Oth ...

  5. zone.js - 暴力之美

    在ng2的开发过程中,Angular团队为我们带来了一个新的库 – zone.js.zone.js的设计灵感来源于Dart语言,它描述JavaScript执行过程的上下文,可以在异步任务之间进行持久性 ...

  6. [bzoj3123][sdoi2013森林] (树上主席树+lca+并查集启发式合并+暴力重构森林)

    Description Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数 ...

  7. HDU 5944 Fxx and string(暴力/枚举)

    传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Othe ...

  8. 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)

    湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...

  9. fragment+viepager 的简单暴力的切换方式

    这里是自定义了一个方法来获取viewpager private static ViewPager viewPager; public static ViewPager getMyViewPager() ...

随机推荐

  1. VisualGDB系列11:Linux C++项目中使用外部Linux库

    根据VisualGDB官网(https://visualgdb.com)的帮助文档大致翻译而成.主要是作为个人学习记录.有错误的地方,Robin欢迎大家指正. 在<使用VS创建Linux静态库和 ...

  2. volatile语义

    volatile在Java内存模型(JMM)中,保证共享变量对所有线程可见,但不保证原子性.volatile语义是同步,通过共享变量的方式,完成线程间的通信. 为什么需要volatile Java内存 ...

  3. 问题:sqlserver 跨服务器连接;结果:Sql Server 跨服务器连接

    Sql Server 跨服务器连接 用openrowset连接远程SQL或插入数据 --如果只是临时访问,可以直接用openrowset --查询示例 select * from openrowset ...

  4. JDBC批处理数据

    JDBC3.0  的增强支持BLOB,CLOB,ARRAY,REF数据类型.的ResultSet对象UPDATEBLOB(),updateCLOB(),updateArray()和updateRef( ...

  5. Caused by: java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor

    Bitmap bmp =BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); Paint paint = new ...

  6. jQuery选择器大全整理

    一.选择网页元素 $(document) //选择整个文档对象 $('#myId') //选择ID为myId的网页元素 $('div.myClass') // 选择class为myClass的div元 ...

  7. php中定义数组的方法

    1.PHP定义数组的格式 数组名=array(); 如:$aa=array();//这样就定义了一个数组, 之后给元素赋值: $aa[0]="9016"; $aa[1]=" ...

  8. linq to sql 不能更新的问题

    今天在项目中用linq更新一个表的时候,结果怎么都更新不了,最蛋疼的是什么异常也不报,发现db.table1.isReadOnly为True 知道问题所在,百度后得到解决办法: 原来是我的表没有增加主 ...

  9. 10.model/view实例(1)

    1.如图显示一个2x3的表格: 思考: 1.QTableView显示这个表 2.QAbstractTableModel作为模型类. 3.文档中找到subclass的描述 When subclassin ...

  10. vue 之 let 和const

    浏览目录 let const let es6新增了let命令,用来声明变量.它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效. 上面代码在代码块之中,分别用let和var声明了 ...