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

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

如果没有缺口就横着竖着枚举一下第三个矩形和合并的矩形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. Java8函数式接口之Predicate<T>

    作用: 这是一个功能接口,因此可以作为lambda表达式或方法引用的赋值目标. 实例: /** * Created by luo on 2017/5/3. */ public class Predic ...

  2. mysql由浅入深探究(四)----mysql事务详解

    什么是事务: 通俗的解释就是对数据库进行的一组完整的操作,这组完整的操作中包含一个或多个操作.解释的太low了,来点官方的:事务就是DBMS中执行的一个完整的逻辑单元,这个逻辑单元中包含一个或者多个操 ...

  3. MVC+Linq+EF笔记

    using (DataContext ctx = new DataContext()) { /*foreach (var item in ctx.employees) { ViewData[" ...

  4. opengl学习资料

    opengl新手指引 https://www.codeproject.com/articles/771225/learning-modern-opengl Learning Modern 3D Gra ...

  5. cf791B(完全图&dfs)

    题目链接:http://codeforces.com/contest/791/problem/B 题意:给出一个无向图,问是否满足若存在边ab, bc则存在边ac: 思路:题意即,对于一个点,其所有子 ...

  6. HDU5340 Three Palindromes

    Three Palindromes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  7. 剑指Offer的学习笔记(C#篇)-- 栈的压入、弹出序列

    题目描述 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压 ...

  8. 定位之float 同一父元素的float相互影响,float是margin盒子在父元素的padding盒子内

  9. 1、CreateJS介绍-EaselJS

    需要在html5文件中引入的CreateJS库文件是easeljs-0.7.1.min.js HTML5文件如下: <!DOCTYPE html> <html lang=" ...

  10. 出现提示ERROR 1289 The 'InnoDB' feature is disabled; you need MySQL built with 'InnoDB' to have IT working

    关闭mysql数据库 在mysql的安装目录中找到my.ini文件找到skip-innodb,在前面加上#号保存,重启mysql服务 OK.