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.

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 test(s)

input

5 1 2 5 5 2

output

5AAAAABBBBBBBBBBCCCCCCCCCC

input

4 4 2 6 4 2

output

6BBBBBBBBBBBBAAAACCAAAACCAAAACCAAAACC

题意是给定三个矩形的长宽,问是否能放在同一个正方形中。

因为是三个矩形填一个正方形,一定有一个矩形的长度为正方形的边长,同时这也是矩形的最大长度(这个yy一下很容易想到)

然后就是模拟了

有两种情况,要么是三个排三行(比如样例一),要么是一横两竖(比如样例二)

要注意排一横两竖的时候ABC分别对应第一二三个矩形,这个顺序不能互换(其实也就是复制粘贴3次啦)

因为细节跪了好几次。。我真是越来越弱了。。

 1 #include<bitset>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<cstring>
 5 #include<iostream>
 6 #include<algorithm>
 7 #define LL long long
 8 #define inf 0x7fffffff
 9 #define pa pair<int,int>
10 #define pi 3.1415926535897932384626433832795028841971
11 using namespace std;
12 inline LL read()
13 {
14     LL x=0,f=1;char ch=getchar();
15     while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
16     while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
17     return x*f;
18 }
19 int x1,y1,x2,y2,x3,y3;
20 int main()
21 {
22     x1=read();y1=read();x2=read();y2=read();x3=read();y3=read();
23     if (x1<y1)swap(x1,y1);
24     if (x2<y2)swap(x2,y2);
25     if (x3<y3)swap(x3,y3);
26     int l=max(max(x1,x2),x3);
27     if (x1*y1+x2*y2+x3*y3!=l*l){printf("-1");return 0;}
28     if (l==x1&&l==x2&&l==x3)
29     {
30         printf("%d\n",l);
31         for (int i=1;i<=y1;i++)
32             {for (int j=1;j<=x1;j++)printf("A");printf("\n");}
33         for (int i=1;i<=y2;i++)
34             {for (int j=1;j<=x2;j++)printf("B");printf("\n");}
35         for (int i=1;i<=y3;i++)
36             {for (int j=1;j<=x3;j++)printf("C");printf("\n");}
37     }else
38     {
39         if (x1==l)
40         {
41             if (x2==l-y1)swap(x2,y2);if (x3==l-y1)swap(x3,y3);
42             if (!(x2+x3==l&&y2+y1==l&&y2==y3)){printf("-1");return 0;}
43             printf("%d\n",l);
44             for (int i=1;i<=y1;i++)
45                 {for (int j=1;j<=x1;j++)printf("A");printf("\n");}
46             for (int i=1;i<=l-y1;i++)
47                 {
48                     for (int j=1;j<=x2;j++)printf("B");
49                     for (int j=1;j<=x3;j++)printf("C");
50                     printf("\n");
51                 }
52         }
53         if (x2==l)
54         {
55             if (x1==l-y2)swap(x1,y1);if (x3==l-y2)swap(x3,y3);
56             if (!(x1+x3==l&&y1+y2==l&&y1==y3)){printf("-1");return 0;}
57             printf("%d\n",l);
58             for (int i=1;i<=y2;i++)
59                 {for (int j=1;j<=x2;j++)printf("B");printf("\n");}
60             for (int i=1;i<=l-y2;i++)
61                 {
62                     for (int j=1;j<=x1;j++)printf("A");
63                     for (int j=1;j<=x3;j++)printf("C");
64                     printf("\n");
65                 }
66         }
67         if (x3==l)
68         {
69             if (x1==l-y3)swap(x1,y1);if (x2==l-y3)swap(x2,y2);
70             if (!(x1+x2==l&&y1+y3==l&&y1==y2)){printf("-1");return 0;}
71             printf("%d\n",l);
72             for (int i=1;i<=y3;i++)
73                 {for (int j=1;j<=x3;j++)printf("C");printf("\n");}
74             for (int i=1;i<=l-y3;i++)
75                 {
76                     for (int j=1;j<=x1;j++)printf("A");
77                     for (int j=1;j<=x2;j++)printf("B");
78                     printf("\n");
79                 }
80         }
81     }
82 }

cf581D

时间: 2024-10-10 02:04:59

cf581D Three Logos的相关文章

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

Logos

[Logos] Logos is a component of the Theos development suite that allows method hooking code to be written easily and clearly, using a set of special preprocessor directives. Logos是Theos的三大组件之一,通过一系列的预处理命令,使得method hooking代码可以写得简单干净. The syntax provid

[iOS越狱开发 之八]Thoes的Logos简介

个人原创,转帖请注明来源:cnblogs.com/jailbreaker 上一篇帖子,讲到使用iOSOpenDev开发基于Theos的Tweak,功能Hook了SpringBoard的 -(void)applicationDidFinishLaunching:(id)application. 先简单讲一下Hook,Hook中文翻译为“钩子”,非常形象,以之上一篇帖子为例子,我们借助Substrate来Hook的,iOS设备运行到applicationDidFinishLaunching方法时候,

Logos讲解--逆向开发

前言 Logos是CydiaSubstruct框架中提供的一组宏定义.利于开发者使用宏进行Hook操作,其语法简单,功能是非常强大且稳定. 详细内容logos语法为http://iphonedevwiki.net/index.php/Logos 语法 1. 全局 Logos语法分为三大类: Block level:这类型的指令会开辟一个代码块,以%end结束.%group.%hook.%subclass.%end Top level:TopLevel指令不放在BlockLevel中.%confi

hdu2328 Corporate Identity 扩展KMP

Beside other services, ACM helps companies to clearly state their "corporate identity", which includes company logo but also other signs, like trademarks. One of such companies is Internet Building Masters (IBM), which has recently asked ACM for

iOS开发者程序许可协议

请仔细阅读下面的许可协议条款和条件之前下载或使用苹果软件.   这些条款和条件构成你和苹果之间的法律协议. 目的 你想使用苹果软件(如下定义)来开发一个或多个应用程序(如下定义)Apple-branded产品运行iOS. 苹果愿意授予您有限的许可使用苹果软件开发和测试您的应用程序在本协议规定的条款和条件. 开发的应用程序在此协议下可以分布在四个方面:(1)通过应用程序商店,如果选择苹果,(2)通过VPP / B2B项目网站,如果选择苹果,(3)在一个有限的基础上使用注册设备(如下定义),和(4)

SOAPUI中文教程---生成测试报告

soapUI有高度的定制可能性; soapUI Pro中可打印的报告基于非常灵活的JasperReports报告引擎. 这些报告是从JasperReports生成的特定的基于XML的模板,可以在项目和全局层面进行定制,从而使您在创建的所有报告中都能轻松获得通用的外观和感觉. 在soapUI中创建可打印报告很容易; 只需从Report对话框中的 Report Type 下拉列表中选择相应的报告,则所选报告将自动编译并按配置生成. Quick tip: 要充分了解soapUI Pro中的报告基础架构

UNIX/Linux 系统管理技术手册阅读(五)

2016.8.17 16:50-17:30 Some important questions to ask are Is this distribution going to be around in five years? Is this distribution going to stay on top of the latest security patches? Is this distribution going to release updated software promptly

uboot1.1.6之NOR FLASH 出现的问题解决方法

U-BOOT移植,structure has no member named `CAMDIVN speed.c: In function `get_HCLK':speed.c:114: error: structure has no member named `CAMDIVN'speed.c: In function `get_PCLK':speed.c:154: error: structure has no member named `CAMDIVN'make[1]: *** [speed.