CF581D 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<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 1000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int h[4], w[4];
char mp[300][300];
char ch[3] = { 'A','B','C' };
int main() {
//ios::sync_with_stdio(0);
for (int i = 1; i <= 3; i++) {
cin >> h[i] >> w[i]; if (h[i] > w[i])swap(h[i], w[i]);
}
if ((w[1] == w[2]&&w[2] == w[3]) && h[1] + h[2] + h[3] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = h[1] + 1; j <= h[2] + h[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[1] + h[2]; j <= w[1]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
else {
int pos = 0;
int maxx = 0;
for (int i = 1; i <= 3; i++) {
if (w[i] > maxx) {
maxx = w[i]; pos = i;
}
}
if (pos == 1) {
if (h[2] + h[3] == w[1]) {
if (w[3] == w[2] && w[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= h[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + h[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (h[2] + w[3] == w[1]) {
if (w[2] == h[3] && w[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= h[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + h[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (w[2] + h[3] == w[1]) {
if (h[2] == w[3] && h[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + w[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
else if (w[2] + w[3] == w[1]) {
if (h[2] == h[3] && h[2] + h[1] == w[1]) {
cout << w[1] << endl;
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= h[1]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1; i <= w[2]; i++) {
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1 + w[2]; i <= w[1]; i++)
for (int j = 1 + h[1]; j <= w[1]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[1]; i++) {
for (int j = 1; j <= w[1]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
} else if (pos == 2) {
if (h[1] + h[3] == w[2]) {
if (w[3] == w[1] && w[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (h[1] + w[3] == w[2]) {
if (h[3] == w[1] && w[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + h[3] == w[2]) {
if (w[3] == h[1] && h[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + w[3] == w[2]) {
if (h[3] == h[1] && h[1] + h[2] == w[2]) {
cout << w[2] << endl;
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= h[2]; j++)mp[i][j] = 'B';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[2]; i++)
for (int j = 1 + h[2]; j <= w[2]; j++)mp[i][j] = 'C';
for (int i = 1; i <= w[2]; i++) {
for (int j = 1; j <= w[2]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
}
else {
if (h[1] + h[2] == w[3]) {
if (w[2] == w[1] && w[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (h[1] + w[2] == w[3]) {
if (h[2] == w[1] && w[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= h[1]; i++) {
for (int j = 1 + h[2]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + h[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + h[2] == w[3]) {
if (w[2] == h[1] && h[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
if (w[1] + w[2] == w[3]) {
if (h[2] == h[1] && h[1] + h[3] == w[3]) {
cout << w[3] << endl;
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= h[3]; j++)mp[i][j] = 'C';
// cout << endl;
}
for (int i = 1; i <= w[1]; i++) {
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'A';
// cout << endl;
}
for (int i = 1 + w[1]; i <= w[3]; i++)
for (int j = 1 + h[3]; j <= w[3]; j++)mp[i][j] = 'B';
for (int i = 1; i <= w[3]; i++) {
for (int j = 1; j <= w[3]; j++)cout << mp[i][j];
cout << endl;
}
return 0;
}
}
} }
cout << -1 << endl;
return 0;
}
CF581D Three Logos 暴力的更多相关文章
- cf581D Three Logos
Three companies decided to order a billboard with pictures of their logos. A billboard is a big squa ...
- 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 ...
- hdu2328 Corporate Identity【string库使用】【暴力】【KMP】
Corporate Identity Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- (KMP 暴力)Corporate Identity -- hdu -- 2328
http://acm.hdu.edu.cn/showproblem.php?pid=2328 Corporate Identity Time Limit: 9000/3000 MS (Java/Oth ...
- zone.js - 暴力之美
在ng2的开发过程中,Angular团队为我们带来了一个新的库 – zone.js.zone.js的设计灵感来源于Dart语言,它描述JavaScript执行过程的上下文,可以在异步任务之间进行持久性 ...
- [bzoj3123][sdoi2013森林] (树上主席树+lca+并查集启发式合并+暴力重构森林)
Description Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数 ...
- HDU 5944 Fxx and string(暴力/枚举)
传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Othe ...
- 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)
湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...
- fragment+viepager 的简单暴力的切换方式
这里是自定义了一个方法来获取viewpager private static ViewPager viewPager; public static ViewPager getMyViewPager() ...
随机推荐
- C#如何生成JSON字符串?(序列化对象)
第一章:C#如何拿到从http上返回JSON数据? 第二章:C#如何解析JSON数据?(反序列化对象) 第三章:C#如何生成JSON字符串?(序列化对象) 第四章:C#如何生成JSON字符串提交给接口 ...
- cookie禁用后重定向跳转时session的跟踪
- 基于C++任意点数的FFT/IFFT(时域和频域)实现
函数说明:更改主函数体中的N和length(=log2(N))既可以实现任意点数(2的幂次)的FFT/ IFFT的实现,fft函数中flag标志位控制是正变换还是逆变换. 1.复数操作类 定 ...
- 【总结整理】webGIS学习
安装ArcGIS Server + ArcSDE + PostgreSQL + ArcMap安装(windows7)博客:https://blog.csdn.net/buqutianya/articl ...
- oracle行转列练习
----------------------第一题--------------------------- create table STUDENT_SCORE ( name ), subject ), ...
- C++实现矩阵的相加/相称/转置/求鞍点
1.矩阵相加 两个同型矩阵做加法,就是对应的元素相加. #include<iostream> using namespace std; int main(){ int a[3][3]={{ ...
- Ajax02 什么是json、json语法、json的使用、利用jQuery实现ajax
目录 1什么是json 2json语法 3json的使用 4利用jQuery实现ajax编程 1 什么是json JavaScript Object Notation(JavaScript 对象表示法 ...
- 阿里云 linux搭建git服务器
git是非常方便的版本控制工具,目前网上有很多免费的git仓库可以给我们使用,但是有些时候我们并不放心将我们的项目寄放在别人的服务器上,这个时候就需要自己搭建一个git服务器. 在linux上面搭建g ...
- 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-002插入排序法(Insertion sort)
一.介绍 1.时间和空间复杂度 运行过程 2.特点: (1)对于已排序或接近排好的数据,速度很快 (2)对于部分排好序的输入,速度快 二.代码 package algorithms.elementar ...
- Java-马士兵设计模式学习笔记-装饰者模式
Java装饰者模式简介 一.假设有一个Worker接口,它有一个doSomething方法,Plumber和Carpenter都实现了Worker接口,代码及关系如下: 1.Worker.java p ...