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.

Examples
Input

Copy
5 1 2 5 5 2
Output

Copy
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input

Copy
4 4 2 6 4 2
Output

Copy
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
暴力就完事了;
代码应该是看不下去的;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 1000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int h[4], w[4];
char mp[300][300];
char ch[3] = { 'A','B','C' };
int main() {
//ios::sync_with_stdio(0);
for (int i = 1; i <= 3; i++) {
cin >> h[i] >> w[i]; if (h[i] > w[i])swap(h[i], w[i]);
}
if ((w[1] == w[2]&&w[2] == w[3]) && h[1] + h[2] + h[3] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = h[1] + 1; j <= h[2] + h[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[1] + h[2]; j <= w[1]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
else {
int pos = 0;
int maxx = 0;
for (int i = 1; i <= 3; i++) {
if (w[i] > maxx) {
maxx = w[i]; pos = i;
}
}
if (pos == 1) {
if (h[2] + h[3] == w[1]) {
if (w[3] == w[2] && w[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= h[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + h[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (h[2] + w[3] == w[1]) {
if (w[2] == h[3] && w[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= h[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + h[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (w[2] + h[3] == w[1]) {
if (h[2] == w[3] && h[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + w[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (w[2] + w[3] == w[1]) {
if (h[2] == h[3] && h[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + w[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
} else if (pos == 2) {
if (h[1] + h[3] == w[2]) {
if (w[3] == w[1] && w[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (h[1] + w[3] == w[2]) {
if (h[3] == w[1] && w[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + h[3] == w[2]) {
if (w[3] == h[1] && h[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + w[3] == w[2]) {
if (h[3] == h[1] && h[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
}
else {
if (h[1] + h[2] == w[3]) {
if (w[2] == w[1] && w[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (h[1] + w[2] == w[3]) {
if (h[2] == w[1] && w[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + h[2] == w[3]) {
if (w[2] == h[1] && h[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + w[2] == w[3]) {
if (h[2] == h[1] && h[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
} }
cout << -1 << endl;
return 0;
}

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. hdu2328 Corporate Identity【string库使用】【暴力】【KMP】

    Corporate Identity Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  4. (KMP 暴力)Corporate Identity -- hdu -- 2328

    http://acm.hdu.edu.cn/showproblem.php?pid=2328 Corporate Identity Time Limit: 9000/3000 MS (Java/Oth ...

  5. zone.js - 暴力之美

    在ng2的开发过程中,Angular团队为我们带来了一个新的库 – zone.js.zone.js的设计灵感来源于Dart语言,它描述JavaScript执行过程的上下文,可以在异步任务之间进行持久性 ...

  6. [bzoj3123][sdoi2013森林] (树上主席树+lca+并查集启发式合并+暴力重构森林)

    Description Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数 ...

  7. HDU 5944 Fxx and string(暴力/枚举)

    传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Othe ...

  8. 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)

    湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...

  9. fragment+viepager 的简单暴力的切换方式

    这里是自定义了一个方法来获取viewpager private static ViewPager viewPager; public static ViewPager getMyViewPager() ...

随机推荐

  1. 分布式爬虫搭建系列 之一------python安装及以及虚拟环境的配置及scrapy依赖库的安装

    python及scrapy框架依赖库的安装步骤: 第一步,python的安装 在Windows上安装Python 首先,根据你的Windows版本(64位还是32位)从Python的官方网站下载Pyt ...

  2. Solaris ssh配置主机间信任关系

    假设需要配置从主机com00biiitf001登录主机ols00biiitf001时不需要密码,则采用以下步骤配置: com00biiitf001上产生公用/私有密钥对 $ ssh-keygen -t ...

  3. cocos2dx帧动画

    //帧动画的创建 //方式一,通过多张图片来创建 auto sprite1 = Sprite::create("grossini_dance_05.png"); sprite1-& ...

  4. windows 7 系统装机优化

    A:系统设置 1.控制面板\系统和安全\Windows Update\更改设置  把系统升级以及提示关闭      控制面板\系统和安全\Windows 防火墙\自定义设置 把专用网络和公共网络的防火 ...

  5. Opencv Laplacian(拉普拉斯算子)

    #include <iostream>#include <opencv2/opencv.hpp>#include <math.h> using namespace ...

  6. 在Ubuntu里安装Mysql5.7.23

    准备在Linux里安装Mysql,安装过程中遇到很多问题,这里记录下我成功安装的过程. 操作系统:Ubuntu 18.04 数据库:Mysql 5.7.23 安装步骤: 1.下载一个apt,下载mys ...

  7. tr td th是什么的缩写

    tr是 table row 表格的行 td是table data th是table heading表格标题 ,一般表格第一行的数据都是table heading

  8. 算法Sedgewick第四版-第1章基础-2.3 Quicksort-001快速排序

    一. 1.特点 (1)The quicksort algorithm’s desirable features are that it is in-place (uses only a small a ...

  9. linux安装thrift

    安装配置Thrift Thrift的编译器使用C++编写的,在安装编译器之前,首先应该保证操作系统基本环境支持C++的编译,安装相关依赖的软件包,如下所示 sudo yum install autom ...

  10. 数据库commit问题

    对数据库进行修改后,需要commit!---之前也是忘记commit导致数据库反应不过来.