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. Kubernetes容器集群管理环境 - Prometheus监控篇

    一.Prometheus介绍之前已经详细介绍了Kubernetes集群部署篇,今天这里重点说下Kubernetes监控方案-Prometheus+Grafana.Prometheus(普罗米修斯)是一 ...

  2. SQL和NoSQL的区别

    一.概念 SQL (Structured Query Language) 数据库,指关系型数据库.主要代表:SQL Server,Oracle,MySQL(开源),PostgreSQL(开源). No ...

  3. 详解阿里P7架构师是怎么在Spring中实现事务暂停

    摘要 Spring框架是一个流行的基于轻量级控制反转容器的Java/J2EE应用框架,尤其在数据访问和事务管理方面的能力是众所周知的.Spring的声明性事务分离可以应用到任何POJO目标对象,并且包 ...

  4. 基于hprose-golang创建RPC微服务

    Hprose(High Performance Remote Object Service Engine) 是一款先进的轻量级.跨语言.跨平台.无侵入式.高性能动态远程对象调用引擎库.它不仅简单易用, ...

  5. dns自动配置shell脚本

    代码: #!/bin/bash #获取url echo "url:" read url #获取ip echo "ip:" read ip #向/etc/name ...

  6. 解读 PHP 的 P++提案

    解读 PHP 的 P++提案 周末看到一篇文章说 PHP 创始人提议将 PHP 拉出新分支,创建 P++ 语言.随后阅读了一下 Zeev Suraski 发起的这个邮件列表,大致了解了一下,这里做个解 ...

  7. 使用ArrayPool池化大型数组(翻译)

    原文链接:https://adamsitnik.com/Array-Pool/ 使用ArrayPool 简介 .NET的垃圾收集器(GC)实现了许多性能优化,其中之一就是,设定年轻的对象很快消亡,然而 ...

  8. springBoot入门教程(图文+源码+sql)

    springBoot入门 1   springBoot 1.1 SpringBoot简介 Spring Boot让我们的Spring应用变的更轻量化.比如:你可以仅仅依靠一个Java类来运行一个Spr ...

  9. node爬虫的几种简易实现方式

    说到爬虫大家可能会觉得很NB的东西,可以爬小电影,羞羞图,没错就是这样的.在node爬虫方面,我也是个新人,这篇文章主要是给大家分享几种实现node 爬虫的方式.第一种方式,采用node,js中的 s ...

  10. sqoop与PG库导入导出数据

    导入数据到Hive sqoop import --connect jdbc:postgresql://172.66.6.666/radar5g4h --username postgres --pass ...