CodeForces 581D Three Logos
爆搜。
#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的更多相关文章
- 「CodeForces 581D」Three Logos
BUPT 2017 Summer Training (for 16) #3A 题意 给你三个矩形,需要不重叠不留空地组成一个正方形.不存在输出-1,否则输出边长和这个正方形(A,B,C表示三个不同矩形 ...
- Round #322 (Div. 2) 581D Three Logos (模拟)
先枚举两个矩形,每个矩形横着放或竖着放,把一边拼起来, 如果不是拼起来有缺口就尝试用第三个矩形去补. 如果没有缺口就横着竖着枚举一下第三个矩形和合并的矩形x或y拼接. #include<bits ...
- codeforces581D
Three Logos CodeForces - 581D Three companies decided to order a billboard with pictures of their lo ...
- 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 #322 (Div. 2) D. Three Logos 模拟
D. Three Logos Three companies decided to order a ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
随机推荐
- build path contains duplicate entry:'src' for project 'XXX'
解决了,原因是编译器配置不正确,原工程使用adk8/android2.3,我用的是最新的4.0,改了下编译环境就好了.
- 确定当前Python环境中的site-packages目录位置
引入“搜索路径”这个概念是因为在使用import语句时,当解释器遇到import语句,如果模块在当前的搜索路径就会被导入. 搜索路径是一个解释器会先进行搜索的所有目录的列表. 那么python如何添加 ...
- androidstudio 问题
Error:(1, 1) A problem occurred evaluating project ':app'. > Failed to apply plugin [id 'com.andr ...
- 图解如何 将Excel里的数据导入到sql server数据库中
项目中,经常会碰到如何将Excel里的数据导入到sql server中的问题. 下面,图解如何实现导入Excel中的数据到sql server 2008 R2: Excel截图如下: 查询pub数据库 ...
- switch case多值匹配
switch case多值匹配一般有两种情况 1.列举(将所有值列举出来) var n= 3;switch (n){ case 1: case 2: case 3: ...
- cssText笔记
style.cssText 用来获取/设置元素的样式 设置: <div id= "a" style= "background: red;"> doc ...
- OpenGL红宝书例3.1 -- glBufferSubData使用
代码实现 1.1 C++部分 GLFWwindow *window; GLuint shader_program; GLuint VAO; void init() { static const GLf ...
- swool安装
swoole安装 安装完PHP后,即可安装swoole扩展. swoole扩展下载地址:https://github.com/swoole/swoole-src/releases 尽量选择stable ...
- ZendStudio格式化HTML代码方法及格式化后错位问题修正
ZendStudio中格式化HTML快捷键:Ctrl+Shift+F 为什么html文件里面的内容格式化完都乱套了? 选 择window菜单->Preferences->Web->H ...
- VIM继承C语言(转)
在下面的基础上加上了astyle sh.c --style=kr --indent=spaces --indent-cases --pad-header --pad-oper --unpad-pare ...