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 ...
随机推荐
- FormsAuthentication.Signout不能清楚服务器端cookie
具体信息可以参考文章 https://support.microsoft.com/en-us/help/900111/the-formsauthentication.signout-method-do ...
- IT兄弟连 Java语法教程 Java语言的跨平台特性
什么是平台 Java是可以跨平台的编程语言,那么首先我们需要知道什么是平台,通常我们把CPU与操作系统的整体称为平台. CPU大家都知道,是计算机的大脑,它既负责思维运算,又负责计算机中各种零部件的命 ...
- vue中修改swiper样式
问题 vue单文件组件中无法修改swiper样式. 解决 1,单文件组件中:新增一个style 不加scoped 让它最终成为全局样式.只在其中操作swiper的样式. <style lang= ...
- java编写jmeter压测脚本
目前项目中接触的比较多的是接口测试,功能测个差不多后会对部分接口进行压测,采用的是java编写脚本,导入jmeter进行压测. 使用到的jmeter的相关包 写一个测试类,继承AbstractJava ...
- 2017浙江工业大学-校赛决赛 BugZhu抽抽抽!!
Description 当前正火的一款手游阴阳师又出新式神了,BugZhu十分想要获得新出的式神,所以他决定花光所有的积蓄来抽抽抽!BugZhu经过长时间的研究后发现通过画三角外接圆能够提高获得该式神 ...
- Mysql 函数创建
DELIMITER $$DROP FUNCTION IF EXISTS `shouy`.`Sel_FUNC_GOODS_type` $$ CREATE FUNCTION `shouy`.`Sel_FU ...
- c#基础3-方法的重载静态和非静态,字段属性,方法
方法的重载概念:方法的重载指的就是方法的名称相同给,但是参数不同.参数不同,分为两种情况1).如果参数的个数相同,那么参数的类型就不能相同.2).如果参数的类型相同,那么参数的个数就不能相同.***方 ...
- 第一课:K线
1 K线是根据价格走势中形成的四个价位(开盘价.收盘价.最高价.最低价)绘制而成的.K线是最基本的描述股价涨跌的表现符号(记录某种股票一天的价格变动情况). K线构造的四个价格因素:开盘价 ...
- When you want to give up, remember why you started.
When you want to give up, remember why you started.当你想要放弃的时候,请记住当初你为何而开始.
- ABAP跳转屏幕
1.call transaction语句跳转屏幕 '. CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN. . 2.调用函数 CALL FUNCTION 'M ...