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() ...
随机推荐
- CentOS7 线上环境的一些 配置
上周服务器被攻击导致上面收回了我们服务器的IP,所以这周重新安装部署了服务器,使用centos7系统.为了防止服务器再次被攻击,所以建议以下几点: 1. root密码要复杂一点,尽量字母数字特殊字符都 ...
- lineNumber: 8; columnNumber: 128; cvc-elt.1: 找不到元素 'beans' 的声明
转自:https://blog.csdn.net/java_yejun/article/details/51036638 spring和mybatis整合时出现了lineNumber: 8; colu ...
- Tiny4412 Linux 内核启动流程
Linux内核的启动分为压缩内核和非压缩内核两种,这里我们以压缩内核为例.压缩内核运行时,将运行一段解压缩程序,得到真正的内核镜像,然后跳转到内核镜像运行.此时,Linux进入非压缩内核入口,在非压缩 ...
- C语言学习笔记--数组指针和指针数组
C 语言中的数组有自己特定的类型,数组的类型由元素类型和数组大小共同决定.(如 int array[5]类型为 int[5]) 1.定义数组类型 C 语言中通过 typedef 为数组类型重命名:ty ...
- css水平居中,竖直居中技巧(一)
css水平居中,竖直居中技巧(一)===### 1.效果 ### 2.代码#### 2.1.index.html <!DOCTYPE html> <html lang="z ...
- 深入理解asp.net中的 __doPostBack函数
前段时间做一个.net网站的时候,用到了模拟前端按钮刷新updatePanel进行局部刷新的时候,遇见了这个问题,当时没顾上记下来,查看网上资料,记下来留着以后查看. 很早以前,当我刚接触asp.NE ...
- ZF 语法
Zend Framework Command Line Console Tool v1.11.11 Details for action "" and provider " ...
- DesertWind TopCoder - 1570
传送门 分析 首先我们要知道为了情况最坏,无论你到哪,一定会在你前往绿洲的最短路上的那片沙子上刮风,所以这个点到绿洲的最短路即为他相连的点中到绿洲距离最短的距离+3和次短的距离+1的最小值,具体实现见 ...
- ARC061E Snuke's Subway Trip
传送门 题目大意 已知某城市的地铁网由一些地铁线路构成,每一条地铁线路由某一个公司运营,该城市规定:若乘坐同一公司的地铁,从开始到换乘只需要一块钱,换乘其他公司的价格也是一块钱,问从1号地铁站到n号地 ...
- Person.post请求------详细过程
首先,在PersonRepository的父类中查找save方法,如下: @Override @TransactionalMethod public <S extends D> S sav ...