D. Three Logos (CF Round #322 (Div.2) 瞎搞 分情况)

来源:互联网 发布:python高级编程最新版 编辑:程序博客网 时间:2024/05/29 18:18
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 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.

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 andyi determine the length and width of the logo of thei-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
题意:三个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*/


0 0