Codeforces Round #322 (Div. 2) D. Three Logos 模拟
2015-10-01 00:07
441 查看
[b] D. Three Logos[/b]
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
output
input
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
///1085422276 #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=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; 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<<-1<<endl;return 0;} if(L==x1&&L==x2&&L==x3){ cout<<L<<endl; FOR(i,1,y1){FOR(j,1,L) { cout<<"A"; } cout<<endl;} FOR(i,1,y2){FOR(j,1,L) { cout<<"B"; } cout<<endl;} FOR(i,1,y3){FOR(j,1,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<<-1<<endl;return 0; } cout<<L<<endl; FOR(i,1,L-y1){ FOR(j,1,x2)cout<<"B"; FOR(j,1,x3)cout<<"C"; cout<<endl; } FOR(i,1,y1){FOR(j,1,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<<-1<<endl;return 0; } cout<<L<<endl; FOR(i,1,L-y2){ FOR(j,1,x1)cout<<"A"; FOR(j,1,x3)cout<<"C"; cout<<endl; } FOR(i,1,y2){FOR(j,1,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<<-1<<endl;return 0; } cout<<L<<endl; FOR(i,1,L-y3){ FOR(j,1,x1)cout<<"A"; FOR(j,1,x2)cout<<"B"; cout<<endl; } FOR(i,1,y3){FOR(j,1,L){ cout<<"C"; }cout<<endl;} } } return 0; }
模拟
相关文章推荐
- The following SDK component was not installed: extra-google-m2repository
- Django基础(一)
- God of War - HDU 2809(状态压缩+模拟)
- go语言之并发
- Django模板系统(非常详细)
- 使用Google Volley框架访问服务端,为Listview加载图片。
- golang echo livereload
- EGORefreshTableHeaderView使用方法(二)
- EGORefreshTableHeaderView、EGORefreshTableFooterView 列表下拉/上拉刷新: (一)
- Mongo 数据模型介绍
- golang 的 import理解实验
- go语言内存分配之TCMalloc
- Google地图实现
- Codeforces Round #322 D Three Logos
- GOOGLE MAP API 如何通过经纬度获取地址信息?
- Google Maps API V3学习一(获取地图坐标与街道地址)
- 如何动态设置django的model field的默认值
- django之todolist(一)
- go struct结构的实例
- Go 面向对象概念