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. IBinder对象在进程间传递的形式(一)

    命题 当service经常被远程调用时,我们经常常使用到aidl来定一个接口供service和client来使用,这个事实上就是使用Binder机制的IPC通信.当client bind servic ...

  2. Linux crontab 命令详解(含配置文件路径)

    编辑/etc/crontab 文件配置cron cron 服务每分钟不仅要读一次/var/spool/cron内的所有文件,还需要读一次/etc/crontab,因此我们配置这个文件也能运用cron服 ...

  3. Configuring the JA-SIG CAS Client --官方

    1. for Java using Spring Configuration of the CAS Client for Java via Spring IoC will depend heavily ...

  4. 大数据笔记04:大数据之Hadoop的HDFS(基本概念)

    1.HDFS是什么? Hadoop分布式文件系统(HDFS),被设计成适合运行在通用硬件(commodity hardware)上的分布式文件系统.它和现有的分布式文件系统有很多共同点. 2.HDFS ...

  5. LVM命令摘要

      命令 描述 物理卷(PV) pvcreate 创建LVM磁盘     #pvcreate /dev/sdb pvdisplay 显示卷组中的物理卷信息 pvchange 设置PV的性能,允许或拒绝 ...

  6. Linux下用rpm方式安装MySQL

    1.MySQL下载地址. www.mysql.com/downloads/mysql-4.0.html 下载MySQL 5.1版本的2个包(根据你的实际需求下载所需要的包): MySQL-server ...

  7. codevs 2451 互不侵犯(状丫dp)

    /* 好神奇好神奇...表示自己要学的还很多 注意到n<=9 不是搜索就是状丫 搜索+剪枝 70分 枚举放或者不放 这里用状丫 f[i][j][k] 表示前i行 放了j个国王 i行的状态是k的方 ...

  8. C#正则怎么判断字符串中是否有汉字

    Regex r = new Regex(".*[\\u4e00-\\u9faf].*");r.IsMatch(username)

  9. VC Windows系统服务创建代码

    Windows系统服务创建步骤,常用类封装,废话不多说,直接上代码 // ServceDemo.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" ...

  10. xAML中一些控件的用法学习

    首先,介绍一些比较简单的设计,这些可以直接通过拖拽实现.如下例子: <Window x:Class="wpf1.MainWindow" xmlns="http:// ...