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

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

如果没有缺口就横着竖着枚举一下第三个矩形和合并的矩形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. SMB SMB2 协议wiki

    from:https://wiki.wireshark.org/SMB2/BufferCode https://msdn.microsoft.com/en-us/library/ee441872.as ...

  2. matlab新手入门(三)(翻译)

    数组索引 MATLAB®中的每个变量都是一个可以容纳多个数字的数组.当您要访问阵列的选定元素时,请使用索引.例如,考虑4乘4A: A = magic(4) A =    16 2 3 13     5 ...

  3. GPLT天梯赛 L2-022. 重排链表

    L2-022. 重排链表 时间限制 500 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 给定一个单链表 L1→L2→...→Ln-1→Ln,请 ...

  4. CSP 201703-4 地铁修建 最小生成树+并查集

    地铁修建   试题编号: 201703-4 试题名称: 地铁修建 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 A市有n个交通枢纽,其中1号和n号非常重要,为了加强运输能力, ...

  5. 基于pthread实现读写锁

    读写锁可用于在多线程访问map等数据结构时使用 #include <pthread.h> class ReadWriteLock { public: ReadWriteLock() { p ...

  6. python反编译之字节码

    如果你曾经写过或者用过 Python,你可能已经习惯了看到 Python 源代码文件:它们的名称以.Py 结尾.你可能还见过另一种类型的文件是 .pyc 结尾的,它们就是 Python "字 ...

  7. lower_bound和upper_bound使用说明

    #include <bits/stdc++.h> using namespace std; int main() { ]; ;i<=;i++) { a[i] = i*; } ;i&l ...

  8. Unite 2017 干货整理 优化篇

    Unite 2017 干货整理 优化篇 2017年05月16日 将Unite 2017的一些演讲做了整理.  本篇有内存,CPU.GC.UI.渲染性能指标.Tips几个小节.  内容持续整理中. 内存 ...

  9. VUE之环境安装

    一.环境安装 软件安装: nodejs https://nodejs.org/en/ vscode https://code.visualstudio.com/docs/?dv=win python- ...

  10. django后台管理系统(admin)的简单使用

    目录 django后台管理系统的使用 检查配置文件 检查根urls.py文件 启动项目,浏览器输入ip端口/admin 如: 127.0.0.1/8000/admin 回车 注册后台管理系统超级管理 ...