Codeforces Round #322 (Div. 2) D. 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.
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.
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
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
4 4 2 6 4 2
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
///
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<bitset>
#include<set>
#include<vector>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a));
#define TS printf("111111\n");
#define FOR(i,a,b) for( int i=a;i<=b;i++)
#define FORJ(i,a,b) for(int i=a;i>=b;i--)
#define READ(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define mod 1000000007
#define inf 100000
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//**************************************** int main()
{ int x1=read(),y1=read(),x2=read(),y2=read(),x3=read(),y3=read();
if(x1<y1)swap(x1,y1);
if(x2<y2)swap(x2,y2);
if(x3<y3)swap(x3,y3);
int L=max(x1,max(x2,x3));
if(L*L!=x1*y1+x2*y2+x3*y3){cout<<-<<endl;return ;}
if(L==x1&&L==x2&&L==x3){
cout<<L<<endl;
FOR(i,,y1){FOR(j,,L)
{
cout<<"A";
}
cout<<endl;}
FOR(i,,y2){FOR(j,,L)
{
cout<<"B";
}
cout<<endl;}
FOR(i,,y3){FOR(j,,L)
{
cout<<"C";
}
cout<<endl;} }
else {
if(x1==L)
{
if (x2==L-y1)swap(x2,y2);if(x3==L-y1)swap(x3,y3);
if(x2+x3!=L||y1+y2!=L||y2!=y3){
cout<<-<<endl;return ;
}
cout<<L<<endl;
FOR(i,,L-y1){
FOR(j,,x2)cout<<"B";
FOR(j,,x3)cout<<"C";
cout<<endl; }
FOR(i,,y1){FOR(j,,L){
cout<<"A";
}cout<<endl;}
}
else if(x2==L)
{
if (x1==L-y2)swap(x1,y1);if (x3==L-y2)swap(x3,y3);
if(x1+x3!=L||y2+y3!=L||y1!=y3){
cout<<-<<endl;return ;
}
cout<<L<<endl;
FOR(i,,L-y2){
FOR(j,,x1)cout<<"A";
FOR(j,,x3)cout<<"C";
cout<<endl; }
FOR(i,,y2){FOR(j,,L){
cout<<"B";
}cout<<endl;}
}else if(x3==L)
{
if (x2==L-y3)swap(x2,y2);if (x1==L-y3)swap(x1,y1);
if(x2+x1!=L||y3+y2!=L||y2!=y1){
cout<<-<<endl;return ;
}
cout<<L<<endl;
FOR(i,,L-y3){
FOR(j,,x1)cout<<"A";
FOR(j,,x2)cout<<"B";
cout<<endl; }
FOR(i,,y3){FOR(j,,L){
cout<<"C";
}cout<<endl;}
}
}
return ;
}
模拟
Codeforces Round #322 (Div. 2) D. Three Logos 模拟的更多相关文章
- Codeforces Round #322 (Div. 2) D. Three Logos 暴力
D. Three Logos Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/problem ...
- Codeforces Round #368 (Div. 2) B. Bakery (模拟)
Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #285 (Div. 2) A B C 模拟 stl 拓扑排序
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列
C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #322 (Div. 2) B. Luxurious Houses 水题
B. Luxurious Houses Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/pr ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #322 (Div. 2)
水 A - Vasya the Hipster /************************************************ * Author :Running_Time * C ...
- Codeforces Round #322 (Div. 2) —— F. Zublicanes and Mumocrates
It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The ...
随机推荐
- docker数据卷的管理和使用
数据卷的使用,数据库可以保证如果容器出现问题但是数据不丢失的作用,比如MySQL/date下的数据 或者Nginx根目录下的index.html 查看数据卷 [root@docker ~]# dock ...
- bin/hadoop checknative
bin/hadoop checknative #检查是否支持本地库 [root@node01 ~]# hadoop checknative19/05/28 23:12:46 INFO bzip2.Bz ...
- 一道超级复杂的js题目
先看以下代码: function Foo(){ getName = function(){ alert(1); }; return this; } Foo.getName = function(){ ...
- 笔试算法题(15):-1到N中包含1的数字的个数 & 连续和为N的序列
出题:输入一个整数N,求从1到N这N个整数的十进制表示中‘1’出现的次数: 分析: 从左向右处理string表示的数字:当前数字长度为n,判断最左边一位数字字符: 如果是0,则直接递归下一位: 如果是 ...
- Mybatis的一级二级缓存
Mybatis提供了缓存机制,可以减轻数据库的压力,提高性能 Mybatis的缓存分为两级:一个是一级缓存,一个二级缓存 一级缓存:即默认使用的缓存SqlSession级别的缓存,只在sqlsessi ...
- About SQL Server 2016 CPT2
SQL Server 2016 CTP2已经发布,可以从以下主页进行下载. http://www.microsoft.com/en-us/server-cloud/products/sql-serve ...
- Webdriver元素定位1
元素的定位应该是自动化测试的核心,要想操作一个元素,首先应该识别这个元素. webdriver提供了一系列的元素定位方法,常用的有以下几种: id name class name tag link t ...
- 63.JPA/Hibernate/Spring Data概念【从零开始学Spring Boot】
[从零开始学习Spirng Boot-常见异常汇总] 事情的起源,无意当中在一个群里看到这么一句描述:"有人么?默默的问一句,现在开发用mybatis还是hibernate还是jpa&quo ...
- Android OkHttp(1)
Android OkHttp(1) OkHttp是一个流行的第三方开源网络请求框架,在目前的一些APP开发中比较流行.Android平台开源的网络请求框架不少,比如常见的Volley, Asyn ...
- Multiprocessing system employing pending tags to maintain cache coherence
A pending tag system and method to maintain data coherence in a processing node during pending trans ...