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 ;
}

模拟

Codeforces Round #322 (Div. 2) D. Three Logos 模拟的更多相关文章

  1. 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 ...

  2. Codeforces Round #368 (Div. 2) B. Bakery (模拟)

    Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...

  3. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #285 (Div. 2) A B C 模拟 stl 拓扑排序

    A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  5. Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列

    C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  6. Codeforces Round #322 (Div. 2) B. Luxurious Houses 水题

    B. Luxurious Houses Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/pr ...

  7. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  8. Codeforces Round #322 (Div. 2)

    水 A - Vasya the Hipster /************************************************ * Author :Running_Time * C ...

  9. Codeforces Round #322 (Div. 2) —— F. Zublicanes and Mumocrates

    It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The ...

随机推荐

  1. mysql图形化工具获取表的源码

    打开数据库,选择要查看的表,点击右键>对象信息>DDL:

  2. python Matplotlib 系列教程(三)——绘制直方图和条形图

    在本章节我们将学习如何绘制条形图和直方图 条形图与直方图的区别:首先,条形图是用条形的长度表示各类别频数的多少,其宽度(表示类别)则是固定的: 直方图是用面积表示各组频数的多少,矩形的高度表示每一组的 ...

  3. 关于统一代码规范ResultBean<T>

    之前看了一篇文章,是java团长的一篇代码规范的文章,很有启发.统一返回格式确实给开发带来方便和美感, 有时候Colltroller返回String或者什么Map,list什么的,虽然都转成json返 ...

  4. PS和AI安装后报代码为16的错误解决方法

    1.问题 2.解决方式 右击属性,改为兼容性运行 参考文章地址:https://www.jb51.net/softjc/308950.html

  5. Linux系统用户、组和权限管理

    一.用户与组 1.用户与组的概念 在linux系统中,根据系统管理需要将用户分为三种类型: 1.超级用户:root是linux系统的超级用户,对系统拥有绝对权限.由于root用户权限太大,只有在进行系 ...

  6. Runlevel in Linux

    运行级别(Runlevel)指的是Unix或者Linux等类Unix操作系统下不同的运行模式.运行级别通常分为7等,分别是从0到6,但如果必要的话也可以更多. 例如在大多数Linux操作系统下一共有如 ...

  7. 合并多个MP4文件

    把多个MP4文件连接起来的方法与音频文件不太一样,比较有效的方法是: $ cat mylist.txt file '/path/to/file1' file '/path/to/file2' file ...

  8. ubuntu 安装python 编程环境

    1. 安装python sudo add-apt-repository ppa:fkrull/deadsnakessudo apt-get updatesudo apt-get install pyt ...

  9. Jbox 弹出窗口 子页面操作完成后关闭 父页面刷新

    父页面js //父页面js <script> var isFreshFlag = '1'; //添加会议活动 function addMeetingAct(){ var attendVip ...

  10. C51 使用端口 个人笔记

    使用整个端口的8个引脚: 八个引脚,需要8位2进制,2位十六进制 #define P0 led led = 0x3f; //led = ~0x3f; 使用某个端口的某一个引脚 sbit led = P ...