Round #322 (Div. 2) 581D Three Logos (模拟)
先枚举两个矩形,每个矩形横着放或竖着放,把一边拼起来,
如果不是拼起来有缺口就尝试用第三个矩形去补。
如果没有缺口就横着竖着枚举一下第三个矩形和合并的矩形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 (模拟)的更多相关文章
- Codeforces Round #322 (Div. 2) D. Three Logos 模拟
D. Three Logos Three companies decided to order a ...
- 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 #368 (Div. 2) B. Bakery (模拟)
Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...
- 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 ...
- Codeforces Round #322 (Div. 2)
水 A - Vasya the Hipster /************************************************ * Author :Running_Time * C ...
- 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 ...
- 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 ...
- Codeforces Round #315 (Div. 2A) 569A Music (模拟)
题目:Click here 题意:(据说这个题的题意坑了不少人啊~~~)题目一共给了3个数---- T 表示歌曲的长度(s).S 表示下载了歌曲的S后开始第一次播放(也就是说S秒的歌曲是事先下载好的) ...
- 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 ...
随机推荐
- 使用VSTO写的一个工作证打印软件
转行做HR近2年.最近公司要做工牌,工牌上要打印照片,姓名,工号和部门等信息.一共1000多人,如果手工排版手工打印的话,估计要死人. 于是coding的老毛病又犯了,想写个程序来打印工牌.还是拿最近 ...
- Thinkphp3.2 下载文件的方法
今天做一个功能,刚好遇到了一个要下载文件功能的需求,所以把这个基于thinkphp3.2的文件下载功能,描述一下大概的实现方法. 网上有人说用a链接的方法实现,但是这种方法并不安全.所以我们还是用官方 ...
- gulp --watch直接退出,并没有监听
1.在es6(彩票项目)搭建环境时遇到gulp --watch 只运行一次就退出了不能监听: D:\nodejs\es6-base>gulp --watch [::] Failed to loa ...
- UE4中资源加载资源的方式
在UNITY中,我们加载资源一般是通过Resources.Load(path).即可完成.该方法返回的是Object类型.如果你想要的是材质或者贴图等等,只要价格类型转换的关键字就可以了例如 as M ...
- 汇总:unity中弹道计算和击中移动目标计算方法
http://download.jikexueyuan.com/detail/id/432.html 弹道计算是游戏里常见的问题,其中关于击中移动目标的自动计算提前量的话题,看似简单,其实还是挺复杂的 ...
- codevs1051接龙游戏
1051 接龙游戏
- uoj#351. 新年的叶子(概率期望)
传送门 数学还是太差了,想了半天都没想出来 首先有一个定理,如果直径(这里考虑经过的点数)为奇数,所有直径有同一个中点,如果直径为偶数,所有直径有同一条最中间的边.这个可以用反证法,假设不成立的话直径 ...
- 1.函数的结构,调用,传参,形参,实参,args,kwargs,名称空间,高阶函数
1.函数的初识 初始函数 获取任意一个字符串的元素的个数 s1='dsjdkjkfefenga' count=0 for i in s1: count+=1 print(count) 获取列表的元素的 ...
- python接口自动化(三十九)- logger 日志 - 上(超详解)
简介 Python的logging模块提供了通用的日志系统,可以方便第三方模块或者是应用使用.这个模块提供不同的日志级别,并可以采用不同的方式记录日志,比如文件,HTTP GET/POST,SMTP, ...
- java获取本机ip的方法
直接上代码: public class LocalIPUtil { public static String getLocalIp(HttpServletRequest request){ Strin ...