博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces #322 div 2 D. Three Logos (枚举)
阅读量:4596 次
发布时间:2019-06-09

本文共 3682 字,大约阅读时间需要 12 分钟。

D. Three Logos
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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
5 AAAAA BBBBB BBBBB CCCCC CCCCC
input
4 4 2 6 4 2
output
6 BBBBBB BBBBBB AAAACC AAAACC AAAACC AAAACC 题意很清楚. 给三个矩形,问能否拼成一个正方形. 我们先把矩形都躺着放(保证x<=y) 然后容易知道,一共有两种可能的方法 一种是三个矩形罗在一起 另外一种是一个矩形在上面,下面两个矩形竖着放. 后一种方法又因为上面的矩形的不同以及下面两个矩形的横竖放置不同(00 01 10 11)*3 所以一共有12种要枚举... 直接写会累死... 想了个简单点的办法,具体见代码. 一遍AC,好爽!!!
1 /*************************************************************************  2     > File Name: code/cf/#322/D.cpp  3     > Author: 111qqz  4     > Email: rkz2013@126.com   5     > Created Time: 2015年09月30日 星期三 17时21分24秒  6  ************************************************************************/  7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 #include
16 #include
17 #include
18 #include
19 #include
20 #define y1 hust111qqz 21 #define yn hez111qqz 22 #define j1 cute111qqz 23 #define ms(a,x) memset(a,x,sizeof(a)) 24 #define lr dying111qqz 25 using namespace std; 26 #define For(i, n) for (int i=0;i
p[i].y) swap(p[i].x,p[i].y);199 ss += p[i].x*p[i].y;200 }201 for ( int i = 0 ; i < 3 ; i++)202 {203 if (p[i].y*p[i].y==ss)204 {205 lst = i;206 }207 }208 if (solve())209 {210 printf("%d\n",ans);211 for ( int i = 0 ; i < ans ; i++)212 {213 for ( int j = 0 ; j < ans ; j++)214 {215 printf("%c",maze[i][j]);216 }217 printf("\n");218 }219 }220 else221 {222 puts("-1");223 }224 #ifndef ONLINE_JUDGE 225 226 fclose(stdin);227 #endif228 return 0;229 }
View Code

 

 

转载于:https://www.cnblogs.com/111qqz/p/4850592.html

你可能感兴趣的文章
C#操作Word文件
查看>>
hihocoder1323 回文字符串
查看>>
MD5加密
查看>>
搜索评价指标——NDCG
查看>>
浅复制与深复制
查看>>
codeReview
查看>>
内存泄漏 tensorflow
查看>>
javascript 体验倒计时:距离国庆还有多长时间
查看>>
centos 7 修改ssh登录端口
查看>>
wraps
查看>>
11、深入理解计算机系统笔记:存储器层次结构,利用局部性
查看>>
小白整理一下PHP常用字符串函数
查看>>
一千行mysql笔记
查看>>
排查Java高CPU占用原因
查看>>
[iOS]数据库第三方框架FMDB详细讲解
查看>>
让IE6/IE7/IE8浏览器支持CSS3属性
查看>>
Windows 某些软件显示"口口"解决办法
查看>>
PHP+Hadoop+Hive+Thrift+Mysql实现数据统计分析
查看>>
和同事下班路上讨论心得(服务器部署的几点问题)
查看>>
Spring学习总结五——SpringIOC容器五
查看>>