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. Android开源项目分类汇总[转]

    Android开源项目分类汇总 如果你也对开源实现库的实现原理感兴趣,欢迎 Star 和 Fork Android优秀开源项目实现原理解析欢迎加入 QQ 交流群:383537512(入群理由需要填写群 ...

  2. C++中的构造函数和析构函数

    构造函数: 在类实例化对象时自动执行,对类中的数据进行初始化.构造函数可以从载,可以有多个,但是只能有一个缺省构造函数. 析构函数: 在撤销对象占用的内存之前,进行一些操作的函数.析构函数不能被重载, ...

  3. pat 1049. Counting Ones (30)

    看别人的题解懂了一些些    参考<编程之美>P132 页<1 的数目> #include<iostream> #include<stdio.h> us ...

  4. cocos2dx3.0 超级马里奥开发笔记(两)——正确的规划游戏逻辑

    我将不得不拿出一个完整的开发笔记.由于个人原因.代码已OK该,博客,那么就不要粘贴代码,直接解释了整个游戏设计,更确切地说,当新手应该注意的地方发展. 1.继承类和扩展作用的权----展阅读(MVC) ...

  5. POJ 1250 Tanning Salon

    Tanning Salon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6822   Accepted: 3686 Des ...

  6. SWFObject文件上传使用记录

    SWFObject文件上传使用方法记录,该插件使用起来相当强大也很灵活,与uploadify各有千秋. 值得一说的是,如果要设置button_image_url这个参数,该参数是按钮的背景图,但是一定 ...

  7. gulp入门学习

    一.gulp简介 gulp是一个自动化构建工具.在开发过工程中,能够使用gulp对项目进行自动构建,大大提高工作效率. 二.安装gulp 在安装gulp之前先要确认已经正确安装了node.js,然后在 ...

  8. 源码搭建lnmp平台

    lnmp平台是指利用linux操作系统,nginx服务器,mysql数据库和php语言搭建高性能web服务器,负载均衡器和邮件代理服务器. 原理图:‘

  9. Interpolator 插值器

    简介 Interpolator:撺改者,校对机,分类机,插补器 Interpolator 定义了动画的变化速度,可以实现匀速.正加速.负加速.无规则变加速等,这使得基本的动画得以实现加速.减速等效果. ...

  10. mockito学习笔记

    mockito http://mockito.github.io/mockito/docs/current/org/mockito/Mockito.html