codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

544B.md (1784B)


      1 Source: https://codeforces.com/problemset/problem/544/B
      2 
      3 B. Sea and Islands
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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).
     22 
     23 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.
     24 
     25 Input
     26 
     27 The single line contains two positive integers *n*, *k* (1 ≤ *n* ≤ 100, 0 ≤ *k* ≤ *n*2) — the size of the map and the number of islands you should form.
     28 
     29 Output
     30 
     31 If the answer doesn't exist, print "NO" (without the quotes) in a single line.
     32 
     33 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*.
     34 
     35 If there are multiple answers, you may print any of them.
     36 
     37 You should not maximize the sizes of islands.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 5 2
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 YES  
     51 SSSSS  
     52 LLLLL  
     53 SSSSS  
     54 LLLLL  
     55 SSSSS
     56 ```
     57 
     58 Input
     59 
     60 ```
     61 5 25
     62 ```
     63 
     64 Output
     65 
     66 ```
     67 NO
     68 ```