B. Marlin

B. 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 (3n993≤n≤990k2×(n2)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
.....
.###.
.....
.....

这题题目意思就是有k个宾馆,我们要把宾馆建在格子里使得两个村庄的人到他们各自喜爱的鱼塘的最短路条数相同,如果存在就输出YES,并给出方案图,注意宾馆不能建在四个边上,否则输出NO,

我们根据样例可以猜下,当k为偶数时,我们就分为上下两部分建宾馆,数量均为k/2,当k为奇数时,第二行先在中心列建一个宾馆,然后在中心的两边一次轮流建宾馆,如果第二行建满了,那么就在第三行建,方式为从第二列和倒数第二列依次轮流往中心建,目的是构造对称

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    cout << "YES" << endl;
    if(m % 2 == 0){
        for(int i = 0; i < n; i ++) cout << ".";
        cout << endl <<".";
        for(int i = 1; i <= m / 2; i ++) cout << "#";
        for(int i = m / 2 + 1; i < n; i ++) cout << ".";
        cout << endl << ".";
        for(int i = 1; i <= m / 2; i ++) cout << "#";
        for(int i = m / 2 + 1; i < n; i ++) cout << ".";
        cout << endl;
        for(int i = 0; i < n; i ++) cout << ".";
        cout << endl;
    }else {
        if(m >= n - 2){
            for(int i = 0; i < n; i ++) cout << ".";
            cout << endl << ".";
            for(int i = 2; i <= n - 1; i ++) cout << "#";
            cout << "." << endl;
            m -= n - 2;
            cout << ".";
            for(int i = 2; i < 2 + m / 2; i ++) cout << "#";
            for(int i = m / 2 + 2; i <= n - 1 - m / 2; i ++) cout << ".";
            for(int i = n - m / 2; i <= n - 1 ; i ++) cout << "#";
            cout << "." <<endl;
            for(int i = 0; i < n; i ++) cout << ".";
            cout << endl;
        }else {
            for(int i = 0; i < n; i ++) cout << ".";
            cout << endl << ".";
            for(int i = 2; i < (n+1) / 2 - (m - 1) / 2; i ++) cout << ".";
            for(int i = (n+1) / 2 - (m - 1) / 2; i <= (n+1) / 2; i ++) cout << "#";
            for(int i = (n+1) / 2 + 1; i < (n+1) / 2 + 1 + (m-1) / 2; i ++) cout << "#";
            for(int i = (n+1) / 2 + 1 + (m-1) / 2; i <= n; i ++) cout << ".";
            cout << endl;
            for(int i = 0; i < n; i ++) cout << ".";
            cout << endl;
            for(int i = 0; i < n; i ++) cout << ".";
            cout << endl;
        }
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值