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
.....
.###.
.....
.....

这是一道天坑题,不存在NO的情况,都是YES;

所以如果K是偶数就先放左边,如果K是奇数就从中间开始放;

题意:

有一个城市有4行n列,n是奇数,有一个村庄在(1,1),村民的活动地点是(4,n);

有一个村庄在(4,1),村民的活动地点是(1,n);

现在要修建k个宾馆,不能修建在边界上,问能否给出一种安排方案使得两个村庄的村民到他们各自的活动地点的最短路的条数相等。

思路:

画了几个实例就应该知道,无论n和k是多少,都可以构建出合理的方案,所以全是YES。

如果k为偶数,那么就上下对称,这个比较好构造;当k为奇数,我采用的是首先把第二排从中间开始向两边填满,然后第三排则是从中间一格的两边开始填。

#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstdio>
#include<time.h>
#include<stack>
#include<queue>
#include<deque>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
char a[][];
int main()
{
int n,k;
cin>>n>>k;
cout<<"YES"<<endl;
if(k%==)
{
for(int i=;i<=k/+;i++)
{
a[][i]='#';
a[][i]='#';
}
}
else
{
if(k<=n-)
{
int p=n/+;
int l=,r=;
for(int i=;i<=k;i++)
{
if(i%==)
{
a[][p+r]='#';
r++;
}
else
{
a[][p-l]='#';
l++;
}
}
}
else
{
for(int i=;i<=n-;i++)
{
a[][i]='#';
}
k=k-n+;
int l=,r=;
for(int i=;i<=k;i++)
{
if(i%==)
{
a[][r]='#';
r++;
}
else
{
a[][n-l]='#';
l++;
}
}
}
}
for(int i=;i<=;i++)
{
for(int j=;j<=n;j++)
{
if(a[i][j]!='#') a[i][j]='.';
else s++;
cout<<a[i][j];
}
cout<<endl;
}
return ;
}

codeforce 980B - Marlin(构造)的更多相关文章

  1. CF980B Marlin 构造 思维 二十四

    Marlin time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  2. codeforces 980B Marlin

    题意: 有一个城市有4行n列,n是奇数,有一个村庄在(1,1),村民的活动地点是(4,n): 有一个村庄在(4,1),村民的活动地点是(1,n): 现在要修建k个宾馆,不能修建在边界上,问能否给出一种 ...

  3. codeforce 1311E. Construct the Binary Tree (构造,就是个模拟)

    ACM思维题训练集合 You are given two integers n and d. You need to construct a rooted binary tree consisting ...

  4. 【构造】Codeforces Round #480 (Div. 2) B. Marlin

    题意:给你一个4*n的网格,保证n为奇数,让你在其中放k个障碍物,不能放在边界的格子上,使得从左上角走到右下角的最短路的方案数,恰好等于从左下角走到右上角的最短路的方案数. k为偶数时,以纵向为对称轴 ...

  5. Two progressions CodeForce 125D 思维题

    An arithmetic progression is such a non-empty sequence of numbers where the difference between any t ...

  6. 学习笔记:Maven构造版本号的方法解决浏览器缓存问题

    需要解决的问题 在做WEB系统开发时,为了提高性能会利用浏览器的缓存功能,其实即使不显式的申明缓存,现代的浏览器都会对静态文件(js.css.图片之类)缓存.但也正因为这个问题导致一个问题,就是资源的 ...

  7. 一步步构造自己的vue2.0+webpack环境

    前面vue2.0和webpack都已经有接触了些(vue.js入门,webpack入门之简单例子跑起来),现在开始学习如何构造自己的vue2.0+webpack环境. 1.首先新建一个目录vue-wk ...

  8. About 静态代码块,普通代码块,同步代码块,构造代码块和构造函数的纳闷

    构造函数用于给对象进行初始化,是给与之对应的对象进行初始化,它具有针对性,函数中的一种.特点:1:该函数的名称和所在类的名称相同.2:不需要定义返回值类型.3:该函数没有具体的返回值.记住:所有对象创 ...

  9. Eos开发——构造查询条件

    1.ajax 方式 var data = { orgid :orgid,year:year ,month: month,type:type,sortField:'sellEmpname' ,sortO ...

随机推荐

  1. protobuf与json转换

    protobuf对象不能直接使用jsonlib去转,因为protobuf生成的对象的get方法返回的类型有byte[],而只有String类型可以作为json的key,protobuf提供方法进行转换 ...

  2. Treflection01_Class对象_构造函数_创建对象

    1. package reflectionZ; import java.lang.reflect.Constructor; import java.util.List; public class Tr ...

  3. Windows下下载及安装numpy、pandas及简单应用

    下载numpy 下载地址 https://pypi.python.org/pypi/numpy 进入网站,下载和自己电脑及电脑中安装的python匹配的numpy版本.我的电脑是Win 10 x64位 ...

  4. hdu2586倍增lca

    求距离 #include<map> #include<set> #include<cmath> #include<queue> #include< ...

  5. uva-1449-AC自动机

    题目链接https://vjudge.net/problem/UVA-1449 题目大意:给出N(N<150)个长度不超过L(70)的匹配串和一个长度小于1e6的文本串,在文本串中找出出现次数最 ...

  6. 【scala】集合框架

  7. pdb 源码索引符号服务器创建过程

    pdb是调试程序必不可少的东西,它保存着一个exe或dll的调试信息,对pdb进行源码索引可以快速找到软件对应该版本的代码,本文以subversion版本控制服务器进行介绍 一.需要安装的软件 win ...

  8. New Concept English three (37)

    28 words/minute 44 typing errors We have learnt to expect that trains will be punctual. After years ...

  9. 移植 MIUI Framework

    移植MIUI Framework 原文:http://www.miui.com/thread-409543-1-1.html 1. 为什么使用代码插桩 首先我们来回顾第一章中的Android软件架构图 ...

  10. HDU - 6185 :Covering(矩阵乘法&状态压缩)

    Bob's school has a big playground, boys and girls always play games here after school. To protect bo ...