D. Three Logos

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.

Sample test(s)
input
5 1 2 5 5 2
output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
input
4 4 2 6 4 2
output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
///
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<bitset>
#include<set>
#include<vector>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a));
#define TS printf("111111\n");
#define FOR(i,a,b) for( int i=a;i<=b;i++)
#define FORJ(i,a,b) for(int i=a;i>=b;i--)
#define READ(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define mod 1000000007
#define inf 100000
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//**************************************** int main()
{ int x1=read(),y1=read(),x2=read(),y2=read(),x3=read(),y3=read();
if(x1<y1)swap(x1,y1);
if(x2<y2)swap(x2,y2);
if(x3<y3)swap(x3,y3);
int L=max(x1,max(x2,x3));
if(L*L!=x1*y1+x2*y2+x3*y3){cout<<-<<endl;return ;}
if(L==x1&&L==x2&&L==x3){
cout<<L<<endl;
FOR(i,,y1){FOR(j,,L)
{
cout<<"A";
}
cout<<endl;}
FOR(i,,y2){FOR(j,,L)
{
cout<<"B";
}
cout<<endl;}
FOR(i,,y3){FOR(j,,L)
{
cout<<"C";
}
cout<<endl;} }
else {
if(x1==L)
{
if (x2==L-y1)swap(x2,y2);if(x3==L-y1)swap(x3,y3);
if(x2+x3!=L||y1+y2!=L||y2!=y3){
cout<<-<<endl;return ;
}
cout<<L<<endl;
FOR(i,,L-y1){
FOR(j,,x2)cout<<"B";
FOR(j,,x3)cout<<"C";
cout<<endl; }
FOR(i,,y1){FOR(j,,L){
cout<<"A";
}cout<<endl;}
}
else if(x2==L)
{
if (x1==L-y2)swap(x1,y1);if (x3==L-y2)swap(x3,y3);
if(x1+x3!=L||y2+y3!=L||y1!=y3){
cout<<-<<endl;return ;
}
cout<<L<<endl;
FOR(i,,L-y2){
FOR(j,,x1)cout<<"A";
FOR(j,,x3)cout<<"C";
cout<<endl; }
FOR(i,,y2){FOR(j,,L){
cout<<"B";
}cout<<endl;}
}else if(x3==L)
{
if (x2==L-y3)swap(x2,y2);if (x1==L-y3)swap(x1,y1);
if(x2+x1!=L||y3+y2!=L||y2!=y1){
cout<<-<<endl;return ;
}
cout<<L<<endl;
FOR(i,,L-y3){
FOR(j,,x1)cout<<"A";
FOR(j,,x2)cout<<"B";
cout<<endl; }
FOR(i,,y3){FOR(j,,L){
cout<<"C";
}cout<<endl;}
}
}
return ;
}

模拟

最新文章

  1. nodejs中获取时间戳、时间差
  2. Android笔记——关于Cursor类的介绍
  3. UnknownHandler
  4. javascript进阶系列专题:闭包(Closure)
  5. HP_UX系统批量创建LV或raw设备的Shell 脚本
  6. Android的开发环境的发展演变
  7. hive[3] 数据类型和文件格式
  8. 13、NFC技术:读写非NDEF格式的数据
  9. Ubuntu 在未知root密码的情况下修改root密码
  10. python包管理器pip
  11. javascript innerHTML、outerHTML、innerText、outerText的区别
  12. JQuery之初探
  13. Oracle进阶研究问题收集
  14. 【云短信】腾讯&amp;阿里
  15. java中的i++与++i的区别以及除法、模的用法(基础)
  16. PyQt5--MainWindow
  17. 使用 IntraWeb (7) - 主模板
  18. Redis 操作数据
  19. C语言 &#183; 十六进制转八进制
  20. DWORD类型

热门文章

  1. java实现 数据结构:链表、 栈、 队列、优先级队列、哈希表
  2. Bootstrap table的基础用法
  3. vue 中动画配置
  4. 笔试算法题(41):线索二叉树(Threaded Binary Tree)
  5. 零基础入门学习Python(16)--序列!序列!
  6. Buffer.from()
  7. mui.openWindow的html5+和web传参的兼容
  8. Python关于函数作为返回值的理解(3分钟就看完了)
  9. 2017 计蒜之道 初赛 第一场 B阿里天池的新任务(简单)
  10. AD采集精度中的LSB