先枚举两个矩形,每个矩形横着放或竖着放,把一边拼起来,

如果不是拼起来有缺口就尝试用第三个矩形去补。

如果没有缺口就横着竖着枚举一下第三个矩形和合并的矩形x或y拼接。

#include<bits/stdc++.h>
using namespace std;
const int N = +;
int ax[][],ay[][];
char g[N][N]; void print_a(int len,int k)
{
printf("%d\n",len);
int ch[] = {'C',k?'B':'A',k?'A':'B'};
for(int i = ; i < ; i++){
for(int x = ax[i][]; x < ax[i][]; x++){
for(int y = ay[i][]; y < ay[i][]; y++){
g[x][y] = ch[i];
}
}
}
for(int i = ; i < len; i++){
for(int j = ; j < len; j++){
if(!g[i][j]) putchar(ch[]);
else putchar(g[i][j]);
}
puts("");
}
} //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int x[],y[];
for(int i = ; i < ; i++) {
scanf("%d%d",x+i,y+i);
//printf("%d %d\n",x[i],y[i]);
} for(int i = ; i <= ; i++){
int c = ,j = i^;
while(c--){
int ct2 = ;
while(ct2--){
int xs = x[i]+x[];
int del = abs(y[]-y[i]);
if(del){
if(xs != max(y[],y[i])) { swap(x[i],y[i]); continue;}
int cx;
if(y[] > y[i]) cx = x[i];
else cx = x[];
int ct = ;
while(ct--){
if(y[j] == del && x[j] == cx ){
ax[][] = x[]; ay[][] = y[];
ax[][] = x[];
ax[][] = x[]+x[i]; ay[][] = y[i];
print_a(xs,i);
return ;
}
swap(x[j],y[j]);
}
}else {
int ct = ;
while(ct--){
if(x[j] == xs && y[i]+y[j] == xs){
ax[][] = x[]; ay[][] = y[];
ax[][] = x[];
ax[][] = x[]+x[i]; ay[][] = y[i];
print_a(xs,i);
return ;
}
if(y[j] == y[i] && xs+x[j] == y[i]){
ax[][] = x[]; ay[][] = y[];
ax[][] = x[];
ax[][] = x[]+x[i]; ay[][] = y[i];
print_a(y[i],i);
return ;
}
swap(x[j],y[j]);
}
}
swap(x[i],y[i]);
}
swap(x[],y[]);
}
}
printf("-1\n");
return ;
}

Round #322 (Div. 2) 581D Three Logos (模拟)的更多相关文章

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

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

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

  3. Codeforces Round #368 (Div. 2) B. Bakery (模拟)

    Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...

  4. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #322 (Div. 2)

    水 A - Vasya the Hipster /************************************************ * Author :Running_Time * C ...

  6. Codeforces Round #285 (Div. 2) A B C 模拟 stl 拓扑排序

    A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  7. Codeforces Round #369 (Div. 2) A B 暴力 模拟

    A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #315 (Div. 2A) 569A Music (模拟)

    题目:Click here 题意:(据说这个题的题意坑了不少人啊~~~)题目一共给了3个数---- T 表示歌曲的长度(s).S 表示下载了歌曲的S后开始第一次播放(也就是说S秒的歌曲是事先下载好的) ...

  9. Codeforces Round #408 (Div. 2)(A.水,B,模拟)

    A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

随机推荐

  1. JAVA学习笔记——(五)

    今日内容介绍 1.方法基础知识 2.方法高级内容 3.方法案例 01方法的概述 * A: 为什么要有方法 * 提高代码的复用性 * B: 什么是方法 * 完成特定功能的代码块. 02方法的定义格式 * ...

  2. Django中ORM外键和表的关系(Django编程-4)

    外键 在MySQL中,表有两种引擎,一种是InnoDB,另外一种是myisam.如果使用的是InnoDB引擎,是支持外键约束的.外键的存在使得ORM框架在处理表关系的时候异常的强大.因此这里我们首先来 ...

  3. 使用ffmpeg编码时,如何设置恒定码率,并控制好关键帧I帧间隔

    1. 大家在使用ffmpeg进行视频编码时,使用-b命令,想控制比特率,却发现结果并没有如我们设置所愿,通过码流分析器观察视频码流,码率的波动还是很大的,ffmpeg控制的并不好,这时候,我们可以通过 ...

  4. 3DMAX 多维材质及对应的UVW展开,UVW贴图

    多维材质说明 多维材质就是一个模型多个材质,(混合材质是多个材质混一起,跟这个貌似没关,比如地表草地,泥土等的混合操作) 作用: 比如一个模型就是需要两种材质,刀的金属刀身,木质刀柄,墙的一面是木板, ...

  5. 洛谷P1228 地毯填补问题

    P1228 地毯填补问题 题目描述 相传在一个古老的阿拉伯国家里,有一座宫殿.宫殿里有个四四方方的格子迷宫,国王选择驸马的方法非常特殊,也非常简单:公主就站在其中一个方格子上,只要谁能用地毯将除公主站 ...

  6. hyperledger fabric 1.0.5 分布式部署 (九)

    linux 使用vim.ctags 配置fabric 源码阅读环境 首先需要安装 ctags,作者使用apt-get 来安装的,安装的版本是5.9 apt-get install ctags 5.9 ...

  7. Eclipse集成Git的实践

    最近一直在研究爬虫的相关技术,网上关于爬虫的教程实在是太少了,只能靠一些零零散散的博客资料做一个浅度的学习,我们已经学习了webcollector,htmlparser,Jsoup这些爬虫技术,并也成 ...

  8. java基础第十一篇之Date、Math、自动装箱和拆箱

    Date类 表示一个瞬间,就是一个时刻 * * 构造方法: * public Date();//创建一个表示当前系统时间的Date对象 * public Date(long time);//毫秒值,距 ...

  9. sublime text 3 的emmet 添加自定义 html 片段

    比如想在html写 jquery 直接添加jquery地址,打开 ‘首选项->Package Setting->Emmet->Settings - User’, css也可以如法炮制 ...

  10. Codeforces Round #561 (Div. 2) A. Silent Classroom

    链接:https://codeforces.com/contest/1166/problem/A 题意: There are nn students in the first grade of Nlo ...