爆搜。

#include<cstdio>
#include<string.h>
#include<math.h>
#include<queue>
#include<algorithm>
using namespace std; int R[],C[];
int r[],c[];
int flag[];
int ans,f; bool check()
{
for(int i=;i<=;i++)
{
r[i]=R[i],c[i]=C[i];
if(flag[i]==) swap(r[i],c[i]);
} if(r[]+r[]+r[]==c[])
{
printf("%d\n",c[]);
for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("A");
printf("\n");
}
for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("B");
printf("\n");
}
for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("C");
printf("\n");
}
return ;
} if(r[]==r[]&&c[]==c[]+c[]&&c[]==r[]+r[])
{
printf("%d\n",c[]); for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("A");
printf("\n");
}
for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("B");
for(int j=;j<=c[];j++) printf("C");
printf("\n");
}
return ;
} if(r[]==r[]&&c[]==c[]+c[]&&c[]==r[]+r[])
{
printf("%d\n",c[]);
for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("B");
printf("\n");
}
for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("A");
for(int j=;j<=c[];j++) printf("C");
printf("\n");
}
return ;
} if(r[]==r[]&&c[]==c[]+c[]&&c[]==r[]+r[])
{
printf("%d\n",c[]); for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("C");
printf("\n");
}
for(int i=;i<=r[];i++) {
for(int j=;j<=c[];j++) printf("A");
for(int j=;j<=c[];j++) printf("B");
printf("\n");
}
return ;
}
return ;
} void dfs(int now)
{
if(now==)
{
if(f==) return;
if(check()==) f=;
return ;
}
flag[now]=; dfs(now+);
flag[now]=; dfs(now+);
} int main()
{
for(int i=;i<=;i++) scanf("%d%d",&R[i],&C[i]);
f=;
dfs();
if(f==) printf("-1\n");
return ;
}

CodeForces 581D Three Logos的更多相关文章

  1. 「CodeForces 581D」Three Logos

    BUPT 2017 Summer Training (for 16) #3A 题意 给你三个矩形,需要不重叠不留空地组成一个正方形.不存在输出-1,否则输出边长和这个正方形(A,B,C表示三个不同矩形 ...

  2. Round #322 (Div. 2) 581D Three Logos (模拟)

    先枚举两个矩形,每个矩形横着放或竖着放,把一边拼起来, 如果不是拼起来有缺口就尝试用第三个矩形去补. 如果没有缺口就横着竖着枚举一下第三个矩形和合并的矩形x或y拼接. #include<bits ...

  3. codeforces581D

    Three Logos CodeForces - 581D Three companies decided to order a billboard with pictures of their lo ...

  4. 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 ...

  5. Codeforces Round #322 (Div. 2) D. Three Logos 模拟

                                                      D. Three Logos Three companies decided to order a ...

  6. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  7. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  8. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  9. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

随机推荐

  1. 二分三角形的时候尤其需要注意!!! HDU 5115 二分+模拟

    题目大意:http://blog.csdn.net/snowy_smile/article/details/49535301 思路:分类讨论,分别在[1,2].(2,3).[3,4).[4,1]相遇, ...

  2. ubuntu 设置vpn

    百度了资料 http://jingyan.baidu.com/article/fa4125aca7f1b628ad709271.html 1. 设置 VPN CONNECTION 2.configur ...

  3. winxp sp2

    不支持sha2,所以ssl建立失败, sp3就可以了 http://superuser.com/questions/802693/sha2-support-for-windows-xp-sp2-any ...

  4. 笨方法学python--变量和命名

    1 =(单等号)和==(双等号)的区别 =用来赋值, ==用来判断是否相等 2 x = 100 在操作符2侧加空格,易读 3 打印时,进行字符串拼接 print "there are&quo ...

  5. c++11 对象池的实现

    ; template <typename T> class ObjectPool { template <typename... Args> using Constructor ...

  6. Stack-overflow, how to answer

    How to Answer Welcome to Stack Overflow! Thanks for taking the time to contribute an answer. It's be ...

  7. 【Android 应用开发】Android 开发 之 JNI入门 - NDK从入门到精通

    NDK项目源码地址 : -- 第一个JNI示例程序下载 : GitHub - https://github.com/han1202012/NDKHelloworld.git -- Java传递参数给C ...

  8. javascript语句语义大全(3)

    1. for(var i=0;i<10;i++){ } for循环,括号里面是循环条件,翻译过来是,初始设定1=0:没循环一次i会+1,直到i<10 2. var i=0: while(i ...

  9. HDU-1301 Jungle Roads(最小生成树[Prim])

    Jungle Roads Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total ...

  10. Chapter 1 First Sight——19

    "I'm headed toward building four, I could show you the way…" Definitely over-helpful. &quo ...