D. Three Logos (CF Round #322 (Div.2) 瞎搞 分情况)
来源:互联网 发布:python高级编程最新版 编辑:程序博客网 时间:2024/05/29 18:18
Three companies decided to order a billboard with pictures of their logos. A billboard is a bigsquare 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 andyi determine the length and width of the logo of thei-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
5AAAAABBBBBBBBBBCCCCCCCCCC
4 4 2 6 4 2
6BBBBBBBBBBBBAAAACCAAAACCAAAACCAAAACC
题意:三个logo,给出他们的长宽,问他们能不能无缝放在一个正方形内。
思路:5种情况在纸上画一下就知道了。
代码:
#include <iostream>#include <functional>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <string>#include <map>#include <stack>#include <vector>#include <set>#include <queue>#pragma comment (linker,"/STACK:102400000,102400000")#define pi acos(-1.0)#define eps 1e-6#define lson rt<<1,l,mid#define rson rt<<1|1,mid+1,r#define FRE(i,a,b) for(i = a; i <= b; i++)#define FREE(i,a,b) for(i = a; i >= b; i--)#define FRL(i,a,b) for(i = a; i < b; i++)#define FRLL(i,a,b) for(i = a; i > b; i--)#define mem(t, v) memset ((t) , v, sizeof(t))#define sf(n) scanf("%d", &n)#define sff(a,b) scanf("%d %d", &a, &b)#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)#define pf printf#define DBG pf("Hi\n")typedef long long ll;using namespace std;#define INF 0X3f3f3f3f#define mod 1000000009const int maxn = 1005;const int MAXN = 10005;const int MAXM = 200010;const int N = 1005;int X1,X2,X3,Y1,Y2,Y3;int r[10];int main(){ int i,j; for (i=1;i<=3;i++) r[i]=i-1; while (~scanf("%d%d%d%d%d%d",&X1,&Y1,&X2,&Y2,&X3,&Y3)) { if (X1>Y1) swap(X1,Y1); if (X2>Y2) swap(X2,Y2); if (X3>Y3) swap(X3,Y3); if (Y1<Y2) { swap(r[1],r[2]); swap(X1,X2); swap(Y1,Y2); } if (Y1<Y3) { swap(r[1],r[3]); swap(X1,X3); swap(Y1,Y3); } if (X1+Y2==Y1 && X1+Y3==Y1 && X2+X3==Y1) { printf("%d\n",Y1); for (i=0;i<X1;i++) { for (j=0;j<Y1;j++) printf("%c",'A'+r[1]); printf("\n"); } for (i=0;i<Y2;i++) { for (j=0;j<X2;j++) printf("%c",'A'+r[2]); for (j=0;j<X3;j++) printf("%c",'A'+r[3]); printf("\n"); } continue; } else if (X1+X2==Y1 && X1+Y3==Y1 && Y2+X3==Y1) { printf("%d\n",Y1); for (i=0;i<X1;i++) { for (j=0;j<Y1;j++) printf("%c",'A'+r[1]); printf("\n"); } for (i=0;i<X2;i++) { for (j=0;j<Y2;j++) printf("%c",'A'+r[2]); for (j=0;j<X3;j++) printf("%c",'A'+r[3]); printf("\n"); } continue; } else if (X1+Y2==Y1 && X1+X3==Y1 && X2+Y3==Y1) { printf("%d\n",Y1); for (i=0;i<X1;i++) { for (j=0;j<Y1;j++) printf("%c",'A'+r[1]); printf("\n"); } for (i=0;i<Y2;i++) { for (j=0;j<X2;j++) printf("%c",'A'+r[2]); for (j=0;j<Y3;j++) printf("%c",'A'+r[3]); printf("\n"); } continue; } else if (X1+X2==Y1 && X1+X3==Y1 && Y2+Y3==Y1) { printf("%d\n",Y1); for (i=0;i<X1;i++) { for (j=0;j<Y1;j++) printf("%c",'A'+r[1]); printf("\n"); } for (i=0;i<X2;i++) { for (j=0;j<Y2;j++) printf("%c",'A'+r[2]); for (j=0;j<Y3;j++) printf("%c",'A'+r[3]); printf("\n"); } continue; } else if (Y2==Y1 && Y3==Y1 && X1+X2+X3==Y1) { printf("%d\n",Y1); for (i=0;i<X1;i++) { for (j=0;j<Y1;j++) printf("%c",'A'+r[1]); printf("\n"); } for (i=0;i<X2;i++) { for (j=0;j<Y2;j++) printf("%c",'A'+r[2]); printf("\n"); } for (i=0;i<X3;i++) { for (j=0;j<Y3;j++) printf("%c",'A'+r[3]); printf("\n"); } continue; } printf("-1\n"); } return 0;}/*5 1 2 5 5 24 4 2 6 4 2*/
- D. Three Logos (CF Round #322 (Div.2) 瞎搞 分情况)
- Codeforces Round #322 (Div. 2) D. Three Logos(暴力)
- Codeforces Round #322 (Div. 2) D. Three Logos
- #322 (div.2) D. Three Logos
- Codeforces Round #322 D.Three Logos
- Codeforces Round #322 D Three Logos
- CF_#322(Div.2) D. Three Logos(greedy)
- CF#322-D. Three Logos-模拟水题
- Codeforces 581D Three Logos
- codeforces 581D Three Logos
- CF Round #424( Div.2) D. Office Keys
- CF Round #240 (Div. 2) D
- Three Logos(模拟)
- Code Forces 581 D. Three Logos(计算几何)
- Codeforces 581D - Three Logos (枚举)
- Codeforces 581D Three Logos 模拟 枚举
- cf-Round #216 (Div. 2) -D Valera and Fools-dfs
- cf Round #292 (Div. 2)D. Drazil and Tiles 构造
- xUtils基本介绍
- 字符编码(一)
- 表达式求值
- 操作系统基础知识(一)
- Android性能调优利器StrictMode
- D. Three Logos (CF Round #322 (Div.2) 瞎搞 分情况)
- Java中wait()与sleep()的区别
- Java基础知识思维导图
- 【9.28】打卡
- 【static&extern,转载,绝佳】再谈下声明、定义、初始化、赋值和extern
- 偏微分方程图像处理序列——连续算子和离散算子对应
- 软件工程导论作业一
- oracle全文检索
- openstack备用机配置