Sea and Islands
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

A map of some object is a rectangular field consisting of n rows and 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 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 islands appear on the n × n map, or determine that no such way exists.

Input

The single line contains two positive integers nk (1 ≤ n ≤ 100, 0 ≤ k ≤ n2) — the size of the map and the number of islands you should form.

Output

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 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.

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

You should not maximize the sizes of islands.

Sample test(s)
input
5 2
output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
input
5 25
output
NO

判下奇偶再输出就行了。人品爆发居然打到了200+,希望这样的狗屎运常来一些。
 #include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <map>
#include <ctime>
using namespace std; int main(void)
{
int n,k;
int max_land; cin >> n >> k; if(n % )
max_land = (n / + + n / ) * (n / ) + n / + ;
else
max_land = n * n / ;
if(max_land < k)
puts("NO");
else
{
puts("YES");
if(n % == )
{
int flag = ;
int count = ;
for(int i = ;i < n;i ++)
{
for(int j = ;j < n;j ++)
if(count < k && (j + flag) % == )
{
cout << 'L';
count ++;
}
else
cout << 'S';
flag = !flag;
cout << endl;
}
}
else
{
int flag = ;
int count = ;
for(int i = ;i < n;i ++)
{
for(int j = ;j < n;j ++)
{
if(count < k && !flag && j % == )
{
cout << 'L';
count ++;
}
else if(count < k && flag && j % )
{
cout << 'L';
count ++;
}
else
cout << 'S';
}
flag = flag == ? : ;
cout << endl;
} }
} return ;
}

最新文章

  1. angular的$filter服务
  2. 图像相似度算法的C#实现及测评
  3. Android 设置闹铃步骤和基础代码
  4. C#中调用API
  5. SQL语句操作文件
  6. [转]iOS开发使用半透明模糊效果方法整理
  7. css 溢出文本显示省略号
  8. Hibernate 、多表关联映射-多对一关系(many-to-one)
  9. python--字符串操作(删除,替换)
  10. 【Spring 核心】AOP 面向切面编程
  11. 爬取西刺网代理ip,并把其存放mysql数据库
  12. UNIX网络编程——客户/服务器程序设计示范(八)
  13. uGUI使用代码动态添加Button.OnClick()事件(Unity3D开发之十二)
  14. [物理学与PDEs]第1章第6节 电磁场的标势与矢势 6.3 例 --- 电偶极辐射
  15. vue-08-axios-get-post-跨域
  16. ASP.NET Web API 启用跨域访问
  17. 动态设置和访问cxgrid列的Properties
  18. indy10的idhttpServer应答字符串
  19. numpy中的广播(Broadcasting)
  20. springcloud16---zuul-filter

热门文章

  1. 集成Jenkins Notifier for Chrome到Jenkins CI
  2. sql 自连接
  3. CentOS 使用yum命令安装出现错误提示&rdquo;could not retrieve mirrorlist http://mirrorlist.centos.org ***&rdquo;
  4. MyEclipse卡死解决
  5. python中使用list作为默认参数且调用时不给其赋值的问题
  6. 使用visual studio 2013 快速搭建phonegap开发环境
  7. PS-文字如何竖排版
  8. Codeforces Round #337 (Div. 2) B. Vika and Squares 贪心
  9. 使用openssl工具生成证书
  10. HANDLER命令与实现