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-10 ;
int Num;
//const int inf=0x7fffffff;
const ll inf=999999999;
inline ll read()
{ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;
}
//*************************************************************************************int a[300][300];
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=1;i<=l1;i++)for(int j=1;j<=r1;j++)a[i][j]=A;for(int i=1;i<=l1;i++)for(int j=r1+1;j<=r1+r2;j++)a[i][j]=B;for(int i=1;i<=l1;i++)for(int j=r1+r2+1;j<=r1+r2+r3;j++)a[i][j]=C;for(int i=1;i<=l1;i++){for(int j=1;j<=l2;j++){if(a[i][j]==1)cout<<"A";else if(a[i][j]==2)cout<<"B";else cout<<"C";}cout<<endl;}return 1;}if(l2+l3!=l1)return 0;if(r1+r2!=l1)return 0;if(r2!=r3)return 0;for(int i=1;i<=l1;i++)for(int j=1;j<=r1;j++)a[i][j]=A;for(int i=1;i<=l2;i++)for(int j=r1+1;j<=r1+r2;j++)a[i][j]=B;for(int i=1;i<=l1;i++)for(int j=1;j<=l1;j++)if(a[i][j]==0)a[i][j]=C;cout<<l1<<endl;for(int i=1;i<=l1;i++){for(int j=1;j<=l1;j++){if(a[i][j]==1)cout<<"A";else if(a[i][j]==2)cout<<"B";else cout<<"C";}cout<<endl;}return 1;}
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//123l1=L1,r1=R1,l2=L2,r2=R2,l3=L3,r3=R3;if(check(l1,r1,l2,r2,l3,r3,1,2,3))return 0;if(check(l1,r1,l2,r2,r3,l3,1,2,3))return 0;if(check(l1,r1,r2,l2,r3,l3,1,2,3))return 0;if(check(r1,l1,l2,r2,l3,r3,1,2,3))return 0;if(check(r1,l1,r2,l2,l3,r3,1,2,3))return 0;if(check(r1,l1,l2,r2,r3,l3,1,2,3))return 0;if(check(l1,r1,r2,l2,r3,l3,1,2,3))return 0;if(check(r1,l1,r2,l2,r3,l3,1,2,3))return 0;//132l1=L1,r1=R1,l2=L3,r2=R3,l3=L2,r3=R2;if(check(l1,r1,l2,r2,l3,r3,1,3,2))return 0;if(check(l1,r1,l2,r2,r3,l3,1,3,2))return 0;if(check(l1,r1,r2,l2,r3,l3,1,3,2))return 0;if(check(r1,l1,l2,r2,l3,r3,1,3,2))return 0;if(check(r1,l1,r2,l2,l3,r3,1,3,2))return 0;if(check(r1,l1,l2,r2,r3,l3,1,3,2))return 0;if(check(l1,r1,r2,l2,r3,l3,1,3,2))return 0;if(check(r1,l1,r2,l2,r3,l3,1,3,2))return 0;//213l1=L2,r1=R2,l2=L1,r2=R1,l3=L3,r3=R3;if(check(l1,r1,l2,r2,l3,r3,2,1,3))return 0;if(check(l1,r1,l2,r2,r3,l3,2,1,3))return 0;if(check(l1,r1,r2,l2,r3,l3,2,1,3))return 0;if(check(r1,l1,l2,r2,l3,r3,2,1,3))return 0;if(check(r1,l1,r2,l2,l3,r3,2,1,3))return 0;if(check(r1,l1,l2,r2,r3,l3,2,1,3))return 0;if(check(l1,r1,r2,l2,r3,l3,2,1,3))return 0;if(check(r1,l1,r2,l2,r3,l3,2,1,3))return 0;//231l1=L2,r1=R2,l2=L3,r2=R3,l3=L1,r3=R1;if(check(l1,r1,l2,r2,l3,r3,2,3,1))return 0;if(check(l1,r1,l2,r2,r3,l3,2,3,1))return 0;if(check(l1,r1,r2,l2,r3,l3,2,3,1))return 0;if(check(r1,l1,l2,r2,l3,r3,2,3,1))return 0;if(check(r1,l1,r2,l2,l3,r3,2,3,1))return 0;if(check(r1,l1,l2,r2,r3,l3,2,3,1))return 0;if(check(l1,r1,r2,l2,r3,l3,2,3,1))return 0;if(check(r1,l1,r2,l2,r3,l3,2,3,1))return 0;//312l1=L3,r1=R3,l2=L1,r2=R1,l3=L2,r3=R2;if(check(l1,r1,l2,r2,l3,r3,3,1,2))return 0;if(check(l1,r1,l2,r2,r3,l3,3,1,2))return 0;if(check(l1,r1,r2,l2,r3,l3,3,1,2))return 0;if(check(r1,l1,l2,r2,l3,r3,3,1,2))return 0;if(check(r1,l1,r2,l2,l3,r3,3,1,2))return 0;if(check(r1,l1,l2,r2,r3,l3,3,1,2))return 0;if(check(l1,r1,r2,l2,r3,l3,3,1,2))return 0;if(check(r1,l1,r2,l2,r3,l3,3,1,2))return 0;//321l1=L3,r1=R3,l2=L2,r2=R2,l3=L1,r3=R1;if(check(l1,r1,l2,r2,l3,r3,3,2,1))return 0;if(check(l1,r1,l2,r2,r3,l3,3,2,1))return 0;if(check(l1,r1,r2,l2,r3,l3,3,2,1))return 0;if(check(r1,l1,l2,r2,l3,r3,3,2,1))return 0;if(check(r1,l1,r2,l2,l3,r3,3,2,1))return 0;if(check(r1,l1,l2,r2,r3,l3,3,2,1))return 0;if(check(l1,r1,r2,l2,r3,l3,3,2,1))return 0;if(check(r1,l1,r2,l2,r3,l3,3,2,1))return 0;cout<<"-1"<<endl;return 0;
}

转载于:https://www.cnblogs.com/qscqesze/p/4845162.html

Codeforces Round #322 (Div. 2) D. Three Logos 暴力相关推荐

  1. 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 ...

  2. Codeforces Round #323 (Div. 1) B. Once Again... 暴力

    B. Once Again... Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/582/probl ...

  3. Codeforces Round #102 (Div. 1) A. Help Farmer 暴力分解

    A. Help Farmer 题目连接: http://www.codeforces.com/contest/142/problem/A Description Once upon a time in ...

  4. Codeforces Round #359 (Div. 2) C. Robbers' watch 暴力枚举

    题目链接 题意是真的烦,到最后才知道是n个m其实就是限定表的两个时区的位数,所以所当数不够填满时区的时候前边自动补零 思路:首先来说不能有重复的数字的话,小时和分钟的总位数大于7肯定不行. 7的7次方 ...

  5. Codeforces Round #552 (Div. 3) E. Two Teams 暴力+双向链表

    传送 题意:将n个人分成2个队,每次选取队伍中未被选取的最大值,然后顺便选取左边相邻的k个数(有多少拿多少) 问你最后队伍的分配情况. #include<bits/stdc++.h>usi ...

  6. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  7. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  8. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

  9. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

  10. Codeforces Round #712 Div.2(A ~ F) 超高质量题解(每日训练 Day.15 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #712 Div.2(A ~ F) 题解 比赛链接:https:// ...

最新文章

  1. 微信小程序wx.request POST获取不到数据解决办法
  2. Html Agility Pack基础类介绍及运用
  3. 关于学习Python的一点学习总结(53)
  4. 如何做产品路线图规划?
  5. mysql 类型转换 cast 将 float 转换为 decimal
  6. Python学习【第6篇】:Python之文件操作
  7. 专访4秒源码商城CTO陈杰:扎根互联网的“不安的心”
  8. java list 占用内存不释放_性能不打折,内存占用减少90%,Facebook提出极致模型压缩方法Quant-Noise...
  9. ​50年来最具影响力的十大编程语言
  10. [转载] 【Python】不用numpy用纯python求极差、平均数、中位数、众数与方差,python的打印到控制台
  11. 7-1 Say Hello to Integers (5 分)
  12. c语言输出语句形式,c语言输出语句是什么
  13. ubuntu记录pdf手写笔记: 数位板(硬件)+xournal(软件)
  14. PLC扩展模块西门子smart200PLC扩展RS485modbus以太网模块
  15. 微信公众号推广的40个有效果的方法
  16. 非线性方程-概念应用及解法
  17. 马云的“虚拟信用卡”动了谁的奶酪?
  18. 域用户账户与计算机账户的区别,域用户账户与本地用户账户的异同是什么?
  19. 如何绘制论文中的图表
  20. 一文解决关于建立时间和保持时间的困惑

热门文章

  1. 质子和中子数量的一点疑问
  2. 工作完成了,切勿激动,一定要先求证
  3. 移动终端的应用杀掉进程后,接收消息启动应用的简要技术说明
  4. 创业失败反思二:领导不认错,不反省
  5. 梦到曦和二字与公司起名
  6. mysql dba环境验收_面对一个全新的环境,作为一个Mysql DBA,首先应该了解什么?
  7. linux 源码包解压编译安装
  8. linux g++ gcc
  9. unity打开excel表格_Unity3D读取之(二)——读取Excel文件内容
  10. 制作Linux系统安装程序,制作自己的rpm包