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. Kubernetes 在知乎上的应用

    从 Mesos 到 Kubernetes 之前的调度框架是基于 Mesos 自研的.采用的语言是 Python.运行了大概两年多的时间了,也一直比较稳定.但随着业务的增长,现有的框架的问题逐渐暴露. ...

  2. js进阶---12-12、jquery事件委托怎么使用

    js进阶---12-12.jquery事件委托怎么使用 一.总结 一句话总结:通过on方法(事件委托),给要绑定事件的元素的祖先绑定事件,从而达到效果. 1.事件委托是什么? 通过事件冒泡,让子元素绑 ...

  3. python学习笔记(excel+requests)

    已经可以对excel简单的操作后 可以开始通过excel写测试用例 读取用例 执行用例 提前写好execl 如图: 下面是代码: #!/usr/bin/env python # -*- coding: ...

  4. Linux 任务控制(bg job fg nohup &) (转)

    常用命令 & 将指令丢到后台中去执行[ctrl]+z 將前台任务丟到后台中暂停jobs 查看后台的工作状态fg %jobnumber 将后台的任务拿到前台来处理bg %jobnumber 将任 ...

  5. 开发常用js代码段

    // 获取http传递的参数export const getRequest = ()=>{ var url = location.search; //获取url中"?"符后的 ...

  6. Device Drivers Should Not Do Power Management

    有人对现有的电源管理提出了意见,认为驱动程序不应该做电源管理,paper地址在这里: http://www.ruf.rice.edu/~mobile/publications/xu2014apsys. ...

  7. spring容器和上下文的理解

    spring容器和上下文的理解 spring框架现在使用的很多,这说明有其独特之处----依赖注入,很简单的四个字,在我们需要对象的时候,spring就可以给我们提供所需要的对象,对象的创建.销毁.管 ...

  8. head插件对elasticsearch 索引文档的增删改查

    1.RESTful接口使用方法 为了方便直观我们使用Head插件提供的接口进行演示,实际上内部调用的RESTful接口.  RESTful接口URL的格式: http://localhost:9200 ...

  9. H264子宏块的划分有哪些?

    每个分割或子宏块都有一个独立的运动补偿.每个 MV 必须被编码.传输,分割的选择也需编 码到压缩比特流中.对大的分割尺寸而言,MV 选择和分割类型只需少量的比特,但运动补偿残差 在多细节区域能量将非常 ...

  10. 你必须知道的495个C语言问题,学习体会四

    本文,我们来学习下指针,这是个梦魇啊.无数次折磨着C语言学习者,无数次的内存泄露,无数次的访问失败,无数次的越界溢出, 这些错误造就的仅仅是一个 跟随者,真正的优秀者必须要正视语言的局限,同时在最大限 ...