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

30 篇文章 0 订阅
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
 
    
题意:三个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 1000000009
const 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 2
4 4 2 6 4 2
*/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值