cf581D Three Logos
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.
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.
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.
5 1 2 5 5 2
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
4 4 2 6 4 2
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的更多相关文章
- CF581D Three Logos 暴力
Three companies decided to order a billboard with pictures of their logos. A billboard is a big squa ...
- 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 ...
- 35+雪花Logos设计灵感
快中秋节放假了,给大家分享一些雪花Logos设计灵感,陶冶下心情吧! 原文地址:http://www.goodfav.com/35-snowflake-logos-ideas-17134.html V ...
- Logos
[Logos] Logos is a component of the Theos development suite that allows method hooking code to be wr ...
- 惊人的CSS和JavaScript动画logos例子
https://codepen.io/lindell/pen/mEVgJP Stack Overflow logo是我最喜欢的logo之一,因为它非常简单,但易于识别.并且这个片段动画点击预览Stac ...
- Codeforces Round #322 (Div. 2) D. Three Logos 模拟
D. Three Logos Three companies decided to order a ...
- Logos讲解--逆向开发
前言 Logos是CydiaSubstruct框架中提供的一组宏定义.利于开发者使用宏进行Hook操作,其语法简单,功能是非常强大且稳定. 详细内容logos语法为http://iphonedevwi ...
- CodeForces 581D Three Logos
爆搜. #include<cstdio> #include<string.h> #include<math.h> #include<queue> #in ...
- 「CodeForces 581D」Three Logos
BUPT 2017 Summer Training (for 16) #3A 题意 给你三个矩形,需要不重叠不留空地组成一个正方形.不存在输出-1,否则输出边长和这个正方形(A,B,C表示三个不同矩形 ...
随机推荐
- JNI调用native方法出现 java.lang.UnsatisfiedLinkError: XXXclass.XXXmethod()异常的解决办法
昨天拿到JNI的Android工程Demo,然后把demo整合到开发的主线工程上,发现调用JNI方法一直抛同一个异常 java.lang.UnsatisfiedLinkError: XXXclass. ...
- Android Studio中自己定义快捷输入块
快捷键:Ctrl + Alt + s,进入Settings >Editor>Live Templates>output中加入一个项,选择第一个Live Template waterm ...
- Xcode7 国际化
1.第一步 HaiTing_xcodeproj.png 2.第二不 HaiTing_xcodeproj 2.png 3.第三步 Localizable_strings.png 5第五步 ZLBMeVi ...
- LSI MegaCli 命令使用4
Dell服务器常用管理命令总结准备新版本的 MegaCli-1.01.24-0.i386.rpm 会把程序安装在/opt下,可以自定义安装目录,例如:rpm --relocate /opt/=/usr ...
- MyEclipse保存文件时 自动格式化代码! 不包括文档注释
设置不格式化 文档注释
- servlet方式通过Cookie记住登录时的用户名和密码
1.建立web工程 2.创建存放servlet的包 3右键包,新建servlet,路径将前面的servlet去掉,只需要doPost和doGet方法 编写servlet CookieServlet.j ...
- mongodb权威指南读书笔记
一个服务器能不能运行多个不同端口的mongo实例? 如果两个对象不相等,hashcode一定不相等:如果两个对象相等,hashcode相等或者不相等? 修改器速度42页 update({},{&quo ...
- Ecstore关于finder的默认的参数row的数据不见了的一些小问题?
在finder中,我们经常对默认的参数row进行数据的编辑处理,然而,在实际处理中,会遇到这么一个问题,该处理的数据不见了,造成这一原因的重要原 因是因为在设置的时候,把某些字段屏蔽掉了,导致返回的r ...
- Wpf解决TextBox文件拖入问题、拖放问题
在WPF中,当我们尝试向TextBox中拖放文件,从而获取其路径时,往往无法成功(拖放文字可以成功).造成这种原因关键是WPF的TextBox对拖放事件处理机制的不同, 解放方法如下: 使用Previ ...
- Android v2.0 基本概念 - 浅谈
目录 Android框架 Linux Kernel 系统运行库 Libraries Android Runtime Application Framework Application Android框 ...