Marlin
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

The city of Fishtopia can be imagined as a grid of 44 rows and an odd number of columns. It has two main villages; the first is located at the top-left cell (1,1)(1,1), people who stay there love fishing at the Tuna pond at the bottom-right cell (4,n)(4,n). The second village is located at (4,1)(4,1) and its people love the Salmon pond at (1,n)(1,n).

The mayor of Fishtopia wants to place kk hotels in the city, each one occupying one cell. To allow people to enter the city from anywhere, hotels should not be placed on the border cells.

A person can move from one cell to another if those cells are not occupied by hotels and share a side.

Can you help the mayor place the hotels in a way such that there are equal number of shortest paths from each village to its preferred pond?

Input

The first line of input contain two integers, nn and kk (3≤n≤993≤n≤99, 0≤k≤2×(n−2)0≤k≤2×(n−2)), nn is odd, the width of the city, and the number of hotels to be placed, respectively.

Output

Print "YES", if it is possible to place all the hotels in a way that satisfies the problem statement, otherwise print "NO".

If it is possible, print an extra 44 lines that describe the city, each line should have nn characters, each of which is "#" if that cell has a hotel on it, or "." if not.

Examples
input

Copy
7 2
output

Copy
YES
.......
.#.....
.#.....
.......
input

Copy
5 3
output

Copy
YES
.....
.###.
.....
.....

题意: 现在有一个4*n的地图,a村庄的人在(1,1),他们要去(4,n),b村庄的人在(4,1),他们要去(1,n),路途的中间有m个酒店,村民不能经过酒店。问怎么设置酒店可以使a、b村庄的人到目的地的最短路大小相同。

题解:通过一番枚举验证,发现只要酒店能关于x轴或者y轴对称,就能满足条件。

然后对比样例,我们不难发现,m使偶数关于x轴对称,为奇数关于y轴对称。

接下来就是按照上面说的构造这样的一个4*n的地图,构造奇数的情况的时候小心一点就行。

#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(a) cout << #a << " " << a << endl
using namespace std;
const int maxn = 1e2 + ;
const int mod = 1e9 + ;
typedef long long ll;
char mapn[maxn][maxn];
int main(){
std::ios::sync_with_stdio(false);
ll n, m;
cin >> n >> m;
cout << "YES" << endl;
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= n; j ++ ) {
mapn[i][j] = '.';
}
}
if( m % == ) {
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= +m/; j ++ ) {
mapn[i][j] = '#';
}
}
} else {
ll t = ( n+ ) / , num = m; //奇数对称的中心点纵坐标是t,num不大于1时不用再填充了,大于1时关于t对称填充
for( ll i = ; i <= ( (m-) / (n-) ) + && num > ; i ++ ) {
for( ll j = ; j <= t- && num > ; j ++ ) {
mapn[i][t-j] = mapn[i][t+j] = '#';
num -= ;
}
}
mapn[][t] = '#';
}
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= n; j ++ ) {
cout << mapn[i][j];
}
cout << endl;
}
return ;
}

CF980B Marlin 构造 思维 二十四的更多相关文章

  1. JAVA之旅(二十四)——I/O流,字符流,FileWriter,IOException,文件续写,FileReader,小练习

    JAVA之旅(二十四)--I/O流,字符流,FileWriter,IOException,文件续写,FileReader,小练习 JAVA之旅林林总总也是写了二十多篇了,我们今天终于是接触到了I/O了 ...

  2. (C/C++学习笔记) 二十四. 知识补充

    二十四. 知识补充 ● 子类调用父类构造函数 ※ 为什么子类要调用父类的构造函数? 因为子类继承父类,会继承到父类中的数据,所以子类在进行对象初始化时,先调用父类的构造函数,这就是子类的实例化过程. ...

  3. 条目二十四《当效率至关重要时,请在map::operator[]与map::insert之间谨慎做出选择》

    条目二十四<当效率至关重要时,请在map::operator[]与map::insert之间谨慎做出选择> 当效率至关重要时,应该在map::operator[]和map::insert之 ...

  4. Bootstrap<基础二十四> 缩略图

    Bootstrap 缩略图.大多数站点都需要在网格中布局图像.视频.文本等.Bootstrap 通过缩略图为此提供了一种简便的方式.使用 Bootstrap 创建缩略图的步骤如下: 在图像周围添加带有 ...

  5. 二十四、Struts2中的UI标签

    二十四.Struts2中的UI标签 Struts2中UI标签的优势: 数据回显 页面布局和排版(Freemark),struts2提供了一些常用的排版(主题:xhtml默认 simple ajax) ...

  6. WCF技术剖析之二十四: ServiceDebugBehavior服务行为是如何实现异常的传播的?

    原文:WCF技术剖析之二十四: ServiceDebugBehavior服务行为是如何实现异常的传播的? 服务端只有抛出FaultException异常才能被正常地序列化成Fault消息,并实现向客户 ...

  7. VMware vSphere 服务器虚拟化之二十四 桌面虚拟化之手动池管理物理机

    VMware vSphere 服务器虚拟化之二十四 桌面虚拟化之手动池管理物理机 VMwareView手动池可以管理物理计算机 说明: 环境基于实验二十三 1.准备一台Windows 7的物理计算机名 ...

  8. Bootstrap入门(二十四)data属性

    Bootstrap入门(二十四)data属性 你可以仅仅通过 data 属性 API 就能使用所有的 Bootstrap 插件,无需写一行 JavaScript 代码.这是 Bootstrap 中的一 ...

  9. 3360: [Usaco2004 Jan]算二十四

    3360: [Usaco2004 Jan]算二十四 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 6  Solved: 6[Submit][Statu ...

随机推荐

  1. Idea搭建Spring+SpringMvc+Mybatis框架集成项目

    1.新建maven项目 2.创建多模块 每个模块配置如父模块一样,除视图层 (视图层配置) 最后 common-通过模块,不依赖任何模块,有各种项目所需要用到的工具类 model- POJO.VO.D ...

  2. [TCP/IP]DNS解析

    DNS解析主机的IP地址 host -t A www.baidu.com

  3. 利用DoHome APP和音箱控制小车的实验参考步骤

    准备材料: Arduino Uno 一块 Arduino 扩展板        购买链接 DT-06模块一个       购买链接 安卓手机一个 小度音箱一个 小车一个 杜邦线若干 1.DT-06固件 ...

  4. docker配置国内镜像地址

    docker的官方镜像站被大天朝强了,今天发现阿里有镜像加速这个功能,目前好像是在公测中,废话不多说,接下来告诉你怎么操作. 点击进入阿里镜像库 https://cr.console.aliyun.c ...

  5. 调用百度翻译 API 来翻译网站信息

    之前说过jquery.i18n.js 来做网站的中英翻译,前提就得做一套中文内容,一套英文内容来解决,好处是中英翻译可以准确无误,本篇文章我们来看一下调用百度翻译的 API 来进行网站的翻译,但是翻译 ...

  6. 【I'm Telling the Truth】【HDU - 3729】 【匈牙利算法,DFS】

    思路 题意:该题主要说几个同学分别说出自己的名次所处区间,最后输出可能存在的未说谎的人数及对应的学生编号,而且要求字典序最大. 思路:刚刚接触匈牙利算法,了解的还不太清楚,附一个专门讲解匈牙利算法的博 ...

  7. 配置Oracle透明网关用以连接 SQLServer经验总结

    一.情景介绍   业务中设计两个不同的系统,系统1和系统2,两个系统分别使用的是Oracle和SQLServer数据库.现需要在系统1的数据库中直接查询系统2数据库的数据.即在Oracle中执行SQL ...

  8. 如何使用WorkManager执行后台任务(下)

    0x00 WorkManager的高级用法 在上一文中已经了解到 WorkManager的基本用法之后,今天来看看它的一些高级用法: 链式任务调用 唯一任务序列 传递参数和获取返回值 0x01 链式任 ...

  9. 一、Ansible入门篇

    一.Ansible简介 Ansible是一个自动化运维的工具 基于python语言编写,因此机器需要具备python环境. 通过ssh的连接方式进行自动化部署,ansible优先使用OpenSSH,在 ...

  10. 2017版 Jetbrains 系列软件激活方法

    1. 到网站 http://idea.lanyus.com/ 获取注册码. 2.填入下面的license server: http://intellij.mandroid.cn/ http://ide ...