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. [摘]Android逆向分析常用网站

    androidterm:   Android Terminal Emulator   http://code.google.com/p/androidterm/   droidbox:   Andro ...

  2. 文件锁简单操作(lockfileEx\unlockfileEx)

    #include "stdafx.h"#include <Windows.h>#include <iostream> using namespace std ...

  3. CIA泄露资料分析(黑客工具&技术)—Windows篇

    背景 近期,维基解密曝光了一系列据称来自美国中央情报局(CIA)网络攻击活动的秘密文件,代号为“Vault 7”,被泄露文件的第一部分名为“Year Zero”,共有8761个文件,包含7818个网页 ...

  4. The R Project for Statistical Computing

    [Home] Download CRAN R Project About R Contributors What’s New? Mailing Lists Bug Tracking Conferenc ...

  5. c#指定程序运行指定文件(太好了,终于找到了)

    System.Diagnostics.Process.Start(@"Notepad.exe", "e:\\a.txt"); System.Diagnostic ...

  6. LAMP 3.5 mysql备份与恢复

    备份库的命令 mysqldump -uroot -pwangshaojun discuz > /data/discuz.sql 指定用户密码,重定向到某文件 恢复 mysql -uroot -p ...

  7. Android屏幕适配终结者

    1,http://blog.csdn.net/zhengjingle/article/details/51742839 github : https://github.com/zhengjingle/ ...

  8. 关于jdk1.5之后的自定拆装箱

    我们都知道jdk在1.5版本之后,增加了一些新特性,我们称之为语法糖,有:1.泛型,2.foreach增强for循环,3.自动拆装箱,4.可变参数,5.枚举,6.静态导入 public class T ...

  9. PHP trim() 函数

    定义和用法 trim() 函数从字符串的两端删除空白字符和其他预定义字符. 语法 trim(string,charlist) 参数 描述 string 必需.规定要检查的字符串. charlist 可 ...

  10. 面试题: 1天的java面试题 已看1

    1,自我介绍下,我直接说的项目经历,(哪年在哪个公司呆过) 2,问是否有带过团队的经历,我说去年带过一次. 3,Struts是单例模式还是多例模式?我先说单例模式,后说多例模式. Struts1是单例 ...