D. Three Logos

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/581/problem/D

Description

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 Input

5 1 2 5 5 2

Sample Output

5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC

HINT

题意

给你三个矩形,问你是否能拼成一个正方形

题解:

啊,能拼的就题目给你的样例的两种方式

那我们就都去尝试咯~

直接暴力枚举就好了,总共就2^3*6*2种搭配,都试试就好了……

代码:

//qscqesze
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 1205000
#define mod 1000000007
#define eps 1e-9
#define e exp(1.0)
#define PI acos(-1)
#define lowbit(x) (x)&(-x)
const double EP = 1E- ;
int Num;
//const int inf=0x7fffffff;
const ll inf=;
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 a[][];
int check(int l1,int r1,int l2,int r2,int l3,int r3,int A,int B,int C)
{
if(l1==l2&&l2==l3&&(r1+r2+r3)==l1)
{
cout<<l1<<endl;
for(int i=;i<=l1;i++)
for(int j=;j<=r1;j++)
a[i][j]=A;
for(int i=;i<=l1;i++)
for(int j=r1+;j<=r1+r2;j++)
a[i][j]=B;
for(int i=;i<=l1;i++)
for(int j=r1+r2+;j<=r1+r2+r3;j++)
a[i][j]=C;
for(int i=;i<=l1;i++)
{
for(int j=;j<=l2;j++)
{
if(a[i][j]==)cout<<"A";
else if(a[i][j]==)cout<<"B";
else cout<<"C";
}
cout<<endl;
}
return ;
}
if(l2+l3!=l1)return ;
if(r1+r2!=l1)return ;
if(r2!=r3)return ;
for(int i=;i<=l1;i++)
for(int j=;j<=r1;j++)
a[i][j]=A;
for(int i=;i<=l2;i++)
for(int j=r1+;j<=r1+r2;j++)
a[i][j]=B;
for(int i=;i<=l1;i++)
for(int j=;j<=l1;j++)
if(a[i][j]==)a[i][j]=C;
cout<<l1<<endl;
for(int i=;i<=l1;i++)
{
for(int j=;j<=l1;j++)
{
if(a[i][j]==)cout<<"A";
else if(a[i][j]==)cout<<"B";
else cout<<"C";
}
cout<<endl;
}
return ; }
int main()
{
int l1,r1,l2,r2,l3,r3;
int L1,R1,L2,R2,L3,R3;
L1=read(),R1=read(),L2=read(),R2=read(),L3=read(),R3=read();
//000 001 010 100 110 101 011 111
//123 132 213 231 312 321
//
l1=L1,r1=R1,l2=L2,r2=R2,l3=L3,r3=R3;
if(check(l1,r1,l2,r2,l3,r3,,,))return ;
if(check(l1,r1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,l2,r2,l3,r3,,,))return ;
if(check(r1,l1,r2,l2,l3,r3,,,))return ;
if(check(r1,l1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,r2,l2,r3,l3,,,))return ;
//
l1=L1,r1=R1,l2=L3,r2=R3,l3=L2,r3=R2;
if(check(l1,r1,l2,r2,l3,r3,,,))return ;
if(check(l1,r1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,l2,r2,l3,r3,,,))return ;
if(check(r1,l1,r2,l2,l3,r3,,,))return ;
if(check(r1,l1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,r2,l2,r3,l3,,,))return ;
//
l1=L2,r1=R2,l2=L1,r2=R1,l3=L3,r3=R3;
if(check(l1,r1,l2,r2,l3,r3,,,))return ;
if(check(l1,r1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,l2,r2,l3,r3,,,))return ;
if(check(r1,l1,r2,l2,l3,r3,,,))return ;
if(check(r1,l1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,r2,l2,r3,l3,,,))return ;
//
l1=L2,r1=R2,l2=L3,r2=R3,l3=L1,r3=R1;
if(check(l1,r1,l2,r2,l3,r3,,,))return ;
if(check(l1,r1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,l2,r2,l3,r3,,,))return ;
if(check(r1,l1,r2,l2,l3,r3,,,))return ;
if(check(r1,l1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,r2,l2,r3,l3,,,))return ;
//
l1=L3,r1=R3,l2=L1,r2=R1,l3=L2,r3=R2;
if(check(l1,r1,l2,r2,l3,r3,,,))return ;
if(check(l1,r1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,l2,r2,l3,r3,,,))return ;
if(check(r1,l1,r2,l2,l3,r3,,,))return ;
if(check(r1,l1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,r2,l2,r3,l3,,,))return ; //
l1=L3,r1=R3,l2=L2,r2=R2,l3=L1,r3=R1;
if(check(l1,r1,l2,r2,l3,r3,,,))return ;
if(check(l1,r1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,l2,r2,l3,r3,,,))return ;
if(check(r1,l1,r2,l2,l3,r3,,,))return ;
if(check(r1,l1,l2,r2,r3,l3,,,))return ;
if(check(l1,r1,r2,l2,r3,l3,,,))return ;
if(check(r1,l1,r2,l2,r3,l3,,,))return ;
cout<<"-1"<<endl;
return ;
}

Codeforces Round #322 (Div. 2) D. Three Logos 暴力的更多相关文章

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

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

  2. Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列

    C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  3. Codeforces Round #322 (Div. 2) B. Luxurious Houses 水题

    B. Luxurious Houses Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/pr ...

  4. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  5. Codeforces Round #322 (Div. 2)

    水 A - Vasya the Hipster /************************************************ * Author :Running_Time * C ...

  6. Codeforces Round #322 (Div. 2) —— F. Zublicanes and Mumocrates

    It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The ...

  7. Codeforces Round #322 (Div. 2) E F

    E. Kojiro and Furrari 题意说的是 在一条直线上 有n个加油站, 每加一单位体积的汽油 可以走1km 然后每个加油站只有一种类型的汽油,汽油的种类有3种 求从起点出发到达终点要求使 ...

  8. 树形dp - Codeforces Round #322 (Div. 2) F Zublicanes and Mumocrates

    Zublicanes and Mumocrates Problem's Link Mean: 给定一个无向图,需要把这个图分成两部分,使得两部分中边数为1的结点数量相等,最少需要去掉多少条边. ana ...

  9. Round #322 (Div. 2) 581D Three Logos (模拟)

    先枚举两个矩形,每个矩形横着放或竖着放,把一边拼起来, 如果不是拼起来有缺口就尝试用第三个矩形去补. 如果没有缺口就横着竖着枚举一下第三个矩形和合并的矩形x或y拼接. #include<bits ...

随机推荐

  1. hdu4619Warm up 2

    http://acm.hdu.edu.cn/showproblem.php?pid=4619 二分图匹配  最小点覆盖 = 最大匹配 #include <iostream> #includ ...

  2. 「拒絕存取路徑 'C:\Users\xxx\AppData\Local\Temp\Temporary ASP.NET Files\apname\3a1b3704\f7fc6d0c\App_Code.l8ieogii.0.cs」的錯誤!

    修改web.config中的system.web->compilation tag中,多加入tempDirectory="可存取的目錄"   <system.web&g ...

  3. BZOJ_1019_[SHOI2008]_汉诺塔_(DP)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1019 汉诺塔游戏,但是有移动优先级,在不违反原有规则的情况下,给定优先移动目标.求完成游戏所需 ...

  4. acdream 小晴天老师系列——晴天的后花园 (暴力+剪枝)

    小晴天老师系列——晴天的后花园 Time Limit: 10000/5000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Others) ...

  5. RHCS集群

    理论基础: User → HA →     Lb    → web → sql → 分布式filesystem ->磁盘I/O 用户   高可用 负载均衡    应用   数据库      mf ...

  6. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.2.9

    (1). When $A$ is normal, the set $W(A)$ is the convex hull of the eigenvalues of $A$. For nonnormal ...

  7. Servlet3.0学习总结(一)——使用注解标注Servlet

    一.Servlet3.0介绍 Servlet3.0是Java EE6规范的一部分,Servlet3.0提供了注解(annotation),使得不再需要在web.xml文件中进行Servlet的部署描述 ...

  8. win7安装gevent时报错 whl is not a supported wheel on this platform.

    1.首先强烈推荐一个站点 在使用pip安装python协程包gevent时,需要很多依赖,很多需要编译的底层支持等等,不能拿来就用.总之很多麻烦的事儿. 这个强烈推荐一个站点,里面都是一些编译好的py ...

  9. 单元测试之获取Spring下所有Bean

    单元测试中,针对接口的测试是必须的,但是如何非常方便的获取Spring注册的Bean呢? 如果可以获取所有的Bean,这样就可以将这个方法放到基类中,方便后面所有单元测试类的使用,具体实现如下: im ...

  10. Java内存结构、类的初始化、及对象构造过程

    概述 网上关于该题目的文章已经很多,我觉得把它们几个关联起来讲可能更好理解一下.与其它语言一样,它在执行我们写的程序前要先分配内存空间,以便于存放代码.数据:程序的执行过程其实依然是代码的执行及数据的 ...