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 ;
}

最新文章

  1. 使用FastReport打印二维码
  2. 如何启动redis
  3. 密钥文件snk
  4. 从源代码的角度分析--在BaseAdapter调用notifyDataSetChanged()之后发生了什么
  5. nusoap
  6. Rest风格WEB服务(Rest Style Web Service)的真相
  7. SQL Server 2005中的分区表(一):什么是分区表?为什么要用分区表?如何创建分区表?(转)
  8. HDU 4968 Improving the GPA
  9. [九度OJ]1431.Sort(寻找前m大数并排序)
  10. libvirt-adabddad
  11. golang channel无缓冲通道会发生阻塞的验证
  12. 数据结构之【栈】+十进制转d进制(堆栈数组模拟)
  13. G1 GC技术解析
  14. sql 查询某个条件多条数据中最新的一条数据或最老的一条数据
  15. SpringBoot标准Properties
  16. iOS设计标注处理方法
  17. jQuery基础(3)- ajax
  18. 牛腩学Kotlin做Android应用
  19. cxGrid使用汇总4
  20. mongodb基本使用(三)

热门文章

  1. java并发之ConcurrentLinkedQueue
  2. 测试通过mweb进行发布Title
  3. java 8中新的日期和时间API
  4. ORACLE 的CONNECT BY、START WITH,CONNECT_BY_ROOT、CONNECT_BY_ISLEAF、SYS_CONNECT_BY_PATH,LEVEL的使用(Hierarchical query-层次查询)
  5. Jquery事件和选择器 纠错
  6. Unity通过NTP获取网络时间
  7. 教老婆学Linux运维(一)初识Linux
  8. 深扒JVM,对它进行“开膛破肚”式解析!
  9. Xamarin Android 监听音量键(下)
  10. 高性能MySQL之事物