CF544B.Sea and Islands

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A map of some object is a rectangular field consisting of nn rows and nn columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly kk islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).

Find a way to cover some cells with sand so that exactly kk islands appear on the n×nn×n map, or determine that no such way exists.

输入格式

The single line contains two positive integers nn , kk ( 1<=n<=1001<=n<=100 , 0<=k<=n20<=k<=n^{2} ) — the size of the map and the number of islands you should form.

输出格式

If the answer doesn't exist, print "NO" (without the quotes) in a single line.

Otherwise, print "YES" in the first line. In the next nn lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal nn .

If there are multiple answers, you may print any of them.

You should not maximize the sizes of islands.

输入输出样例

  • 输入#1

    5 2
    

    输出#1

    YES
    SSSSS
    LLLLL
    SSSSS
    LLLLL
    SSSSS
    
  • 输入#2

    5 25
    

    输出#2

    NO
    
首页