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表示三个不同矩形 ...
随机推荐
- 泛泰A870刷4.4专用英文版非触摸CWM Recovery 6.0.4.8(三版通刷)
首先声明. 发此Recovery的目的是測试能否够三版都能够启动. 而且不会出现像850 860之前出现过的卡第一屏问题! 不希望看到某些人士的过度解读!! 此Recovery能够刷第三方4.4 RO ...
- Linux应用程序打包
原文地址:http://blog.solrex.cn/articles/packaging-1-src.html1. 应用程序打包技术之一(源代码篇) 相信很多朋友都曾经为方便做某件事写过自己的小 ...
- NSRunLoop(来自官方文档)
The NSRunLoop class declares the programmatic interface to objects that manage input sources. An NSR ...
- linux性能调优概述
- 什么是性能调优?(what) - 为什么需要性能调优?(why) - 什么时候需要性能调优?(when) - 什么地方需要性能调优?(where) - 什么人来进行性能调优?(who) - 怎么样 ...
- Oracle 空间管理
表空间:组数据文件的一种途径 分类: 目录表空间(sysaux) 常表空间(system) 系统临时表空间(temp) 用户临时表空间(user) undo表空间 创建表空间: //表空间名为name ...
- php function_name($type=0,$order_ids='',$flag=2)
$order_ids='',表示$order_ids是字符串,不是数组 foreach ($order_ids as $key=>$order_id){ //TODO} 这 ...
- mysql source命令导入sql文件效率分析和索引整理
Query OK, 24918 rows affected (0.90 sec)Records: 24918 Duplicates: 0 Warnings: 0 Query OK, 24923 r ...
- mssql SUBSTRING和charindex的用法
在工作中用到的例子: select * FROM [CSGDC.DataETLDB].[dbo].[StrategiesList] where strategy_name like '%基建系统%' ...
- IOS开发,如何用最新的Itunes给手机装ipa文件
搜了半天,发现网上的很多教“使用Itunes给手机装ipa文件”文字都好几年了,现在的Itunes跟过去几年的功能和界面都有很大改变,话不多说直接两句话讲明白,希望帮到需要的人. 使用Itunes给手 ...
- JavaScript 之 使用 XMLHttpRequest 上传文件
<div id="div1"> <input type="file" id="uploadfile" style=&quo ...