codeforces-scrape

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

1600J.md (1613B)


      1 Source: https://codeforces.com/problemset/problem/1600/J
      2 
      3 J. Robot Factory
      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 You have received data from a Bubble bot. You know your task is to make factory facilities, but before you even start, you need to know how big the factory is and how many rooms it has. When you look at the data you see that you have the dimensions of the construction, which is in rectangle shape: N x M.
     22 
     23 Then in the next N lines you have M numbers. These numbers represent factory tiles and they can go from 0 to 15. Each of these numbers should be looked in its binary form. Because from each number you know on which side the tile has walls. For example number 10 in it's binary form is 1010, which means that it has a wall from the North side, it doesn't have a wall from the East, it has a wall on the South side and it doesn't have a wall on the West side. So it goes North, East, South, West.
     24 
     25 It is guaranteed that the construction always has walls on it's edges. The input will be correct.
     26 
     27 Your task is to print the size of the rooms from biggest to smallest.
     28 
     29 Input
     30 
     31 The first line has two numbers which are N and M, the size of the construction. Both are integers:
     32 
     33 $n$ ($1 \leq n \leq 10^3$)
     34 
     35 $m$ ($1 \leq m \leq 10^3$)
     36 
     37 Next N x M numbers represent each tile of construction.
     38 
     39 Output
     40 
     41 Once you finish processing the data your output consists of one line sorted from biggest to smallest room sizes.
     42 
     43 Example
     44 
     45 Input
     46 
     47 ```
     48 4 5
     49 9 14 11 12 13
     50 5 15 11 6 7
     51 5 9 14 9 14
     52 3 2 14 3 14
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 9 4 4 2 1
     59 ```