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

题意是给定三个矩形的长宽,问是否能放在同一个正方形中。

因为是三个矩形填一个正方形,一定有一个矩形的长度为正方形的边长,同时这也是矩形的最大长度(这个yy一下很容易想到)

然后就是模拟了

有两种情况,要么是三个排三行(比如样例一),要么是一横两竖(比如样例二)

要注意排一横两竖的时候ABC分别对应第一二三个矩形,这个顺序不能互换(其实也就是复制粘贴3次啦)

因为细节跪了好几次。。我真是越来越弱了。。

 #include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
#define inf 0x7fffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
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 x1,y1,x2,y2,x3,y3;
int main()
{
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(max(x1,x2),x3);
if (x1*y1+x2*y2+x3*y3!=l*l){printf("-1");return ;}
if (l==x1&&l==x2&&l==x3)
{
printf("%d\n",l);
for (int i=;i<=y1;i++)
{for (int j=;j<=x1;j++)printf("A");printf("\n");}
for (int i=;i<=y2;i++)
{for (int j=;j<=x2;j++)printf("B");printf("\n");}
for (int i=;i<=y3;i++)
{for (int j=;j<=x3;j++)printf("C");printf("\n");}
}else
{
if (x1==l)
{
if (x2==l-y1)swap(x2,y2);if (x3==l-y1)swap(x3,y3);
if (!(x2+x3==l&&y2+y1==l&&y2==y3)){printf("-1");return ;}
printf("%d\n",l);
for (int i=;i<=y1;i++)
{for (int j=;j<=x1;j++)printf("A");printf("\n");}
for (int i=;i<=l-y1;i++)
{
for (int j=;j<=x2;j++)printf("B");
for (int j=;j<=x3;j++)printf("C");
printf("\n");
}
}
if (x2==l)
{
if (x1==l-y2)swap(x1,y1);if (x3==l-y2)swap(x3,y3);
if (!(x1+x3==l&&y1+y2==l&&y1==y3)){printf("-1");return ;}
printf("%d\n",l);
for (int i=;i<=y2;i++)
{for (int j=;j<=x2;j++)printf("B");printf("\n");}
for (int i=;i<=l-y2;i++)
{
for (int j=;j<=x1;j++)printf("A");
for (int j=;j<=x3;j++)printf("C");
printf("\n");
}
}
if (x3==l)
{
if (x1==l-y3)swap(x1,y1);if (x2==l-y3)swap(x2,y2);
if (!(x1+x2==l&&y1+y3==l&&y1==y2)){printf("-1");return ;}
printf("%d\n",l);
for (int i=;i<=y3;i++)
{for (int j=;j<=x3;j++)printf("C");printf("\n");}
for (int i=;i<=l-y3;i++)
{
for (int j=;j<=x1;j++)printf("A");
for (int j=;j<=x2;j++)printf("B");
printf("\n");
}
}
}
}

cf581D

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. 35+雪花Logos设计灵感

    快中秋节放假了,给大家分享一些雪花Logos设计灵感,陶冶下心情吧! 原文地址:http://www.goodfav.com/35-snowflake-logos-ideas-17134.html V ...

  4. Logos

    [Logos] Logos is a component of the Theos development suite that allows method hooking code to be wr ...

  5. 惊人的CSS和JavaScript动画logos例子

    https://codepen.io/lindell/pen/mEVgJP Stack Overflow logo是我最喜欢的logo之一,因为它非常简单,但易于识别.并且这个片段动画点击预览Stac ...

  6. Codeforces Round #322 (Div. 2) D. Three Logos 模拟

                                                      D. Three Logos Three companies decided to order a ...

  7. Logos讲解--逆向开发

    前言 Logos是CydiaSubstruct框架中提供的一组宏定义.利于开发者使用宏进行Hook操作,其语法简单,功能是非常强大且稳定. 详细内容logos语法为http://iphonedevwi ...

  8. CodeForces 581D Three Logos

    爆搜. #include<cstdio> #include<string.h> #include<math.h> #include<queue> #in ...

  9. 「CodeForces 581D」Three Logos

    BUPT 2017 Summer Training (for 16) #3A 题意 给你三个矩形,需要不重叠不留空地组成一个正方形.不存在输出-1,否则输出边长和这个正方形(A,B,C表示三个不同矩形 ...

随机推荐

  1. PHP5.4新特性(转)

    PHP5.4正式前两天发布了,之前有看了一些PHP5.4主要特性相关文章,因此在这里小结一下. 其中好几点更新是由Laruence贡献的!本文部分内容也是源自Laruence的博客. 1. Buid- ...

  2. 安装apache重启的时候,报错端口被占用,错误1

    在cmd中执行以下命令来重新分配. netsh winsock reset. 还不行的话可以重启电脑,再不行就算apache配置文件错误.

  3. Android 连接Wifi和创建Wifi热点 demo

    android的热点功能不可见,用了反射的技术搞定之外. Eclipse设置语言为utf-8才能查看中文注释 上代码: MainActivity.java package com.widget.hot ...

  4. Android -- getSystemService

    Android的后台运行在很多service,它们在系统启动时被SystemServer开启,支持系统的正常工作,比如MountService监听是否有SD卡安装及移除,ClipboardServic ...

  5. ASP.NET-FineUI开发实践-2

    FineUI好处之一在于No JS,这里的No JS并不是不使用JS,JS对于ASP.Net是必不可少的,只是FineUI把大部分JS封装,如果想用,后台提供了很多方法返回JS,Get...Refer ...

  6. 原生js-拉勾网首页效果

    拉勾网首页公司广告位的悬浮划过效果着实很吸引我.如下(不会做动图!--,感兴趣的可以去拉勾看看): 此处最吸引我的地方在于将鼠标划过上面一排公司列表时,感觉像是绿色的区块跟着你的鼠标移动一样,颇有动感 ...

  7. ARGB和RGB

    ARGB 一种色彩模式,也就是RGB色彩模式附加上Alpha(透明度)通道,常见于32位位图的存储结构. ARGB---Alpha,Red,Green,Blue. Alpha-图像通道 如果图形卡具有 ...

  8. 连接、关联、JOIN、APPLY(SQL Server)

    连接方式 连接类型 个人总结 阐述(生成两个集合的约束笛卡儿积) INNER    JOIN 内连接 关联相同的(用于查找关联的信息) FROM C AS c INNER JOIN D AS d ON ...

  9. 使用ecshop电子商务系统的100个小问题

    1:如何修改网站"欢迎光临本店" 回答:languages\zh_cn\common.php文件中, $_LANG['welcome'] = '欢迎光临本店';将他修改成你需要的字 ...

  10. php实现冒泡排序

    冒泡排序是非常容易理解和实现,,以从小到大排序举例:设数组长度为N.1.比较相邻的前后二个数据,如果前面数据大于后面的数据,就将二个数据交换.2.这样对数组的第0个数据到N-1个数据进行一次遍历后,最 ...