#P4714. Sea and Islands

Sea and Islands

Sea and Islands

题面翻译

题意:给定n和k,求在n*n的矩阵中能否填出k座岛。(S表示海,L表示岛,上下左右相邻的L算作一个岛)。

题目描述

A map of some object is a rectangular field consisting of n n rows and n n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k k 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 k k islands appear on the n×n n×n map, or determine that no such way exists.

输入格式

The single line contains two positive integers n n , k k ( 1<=n<=100 1<=n<=100 , 0<=k<=n2 0<=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 n n 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 n n .

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

You should not maximize the sizes of islands.

样例 #1

样例输入 #1

5 2

样例输出 #1

YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS

样例 #2

样例输入 #2

5 25

样例输出 #2

NO