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. Java多线程 - 线程同步

    多线程操作同一个对象时,容易引发线程安全问题.为了解决线程安全问题,Java多线程引入了同步监视器. 同步代码块 同步代码块语法格式如下: synchronized(obj){ //此处的代码即为同步 ...

  2. JNI_Z_08_创建Java对象

    1.步骤 : (1).获取 jclass (2).获取 构造函数的 method id (方法的名称始终为"<init>") (3).创建Java对象的两种方式: (3 ...

  3. Springer Latex投稿

    大家好.我最近需要向springer旗下一期刊投稿,是用latex编写的.已经调试过,格式和出版的期刊比较接近.因为是第一次投国外期刊,所以没什么经验,在网上搜索了一些帖子,发现在投稿过程中还会出现这 ...

  4. 栈的基本操作--java实现

    package com.wyl.linklist; /** * 栈的定义及相关操作 * 用数组实现栈 * 栈是一个线性表,不过进栈和出栈操作在表尾操作 * @author wyl * */ publi ...

  5. mysql建立索引

    mysql的几种索引http://jingyan.baidu.com/article/da1091fbd166ff027849d687.html

  6. [javascript]JS如何获取当前时间戳

    [javascript]JS如何获取当前时间戳 一.总结 一句话总结:var timestamp = Date.parse(new Date()); 结果是带三位毫秒的,再除个1000取整即可 1.j ...

  7. freemarker报 java.io.FileNotFoundException:及TemplateLoader使用

    使用过freemarker的肯定其见过如下情况: java.io.FileNotFoundException: Template xxx.ftl not found. 模板找不到.可能你会认为我明明指 ...

  8. 卸载mac多余的音频驱动:internal audio driver corel painter

    $ kextstat | grep corel 130 0 0xffffff7f81042000 0x4000 0x4000 com.corel.painter.PainterAudioDriver ...

  9. git如何回滚远程仓库

    git如何回滚远程仓库 http://www.cnblogs.com/iloveyou-sky/p/6534409.html

  10. C++多态、虚函数、纯虚函数、抽象类

    多态 同一函数调用形式(调用形式形同)可以实现不同的操作(执行路径不同),就叫多态. 两种多态: (1)静态多态:分为函数重载和运算符重载,编译时系统就能决定调用哪个函数. (2)动态多态(简称多态) ...