308937: CF1600J. Robot Factory
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Robot Factory
题意翻译
**题目描述** 有一个 $N$ x $M$ 的工厂。然后在接下来的 $N$ 行中,输入 $M$ 个数字。 这些数字代表工厂的瓷砖,这些数字从 $0$ 到 $15$ (二进制为四位)。 每一个数字都以二进制形式查看。因为从每个数字中你可以知道这块瓷砖的哪一个方向有墙。 | 二进制位 | 说明 | | -------- | ---------------------------- | | 第1位 | 为1表示**上边**有墙,0则没有 | | 第2位 | 为1表示**右边**有墙,0则没有 | | 第3位 | 为1表示**下边**有墙,0则没有 | | 第4位 | 为1表示**左边**有墙,0则没有 | 例如,数字 $10$ 的二进制形式是 $1010$ ,这意味着它在上边有一堵墙,下边也有一堵墙,其他方向则没有。 每个相同的瓷砖表示一个房间,请输出所有房间的大小(房间尺寸从大到小进行排序)。 以样例 $1$ 以为例: ![样例1说明](https://s1.imagehub.cc/images/2021/10/12/CF1600J.png) 所有房间的大小依次排序就是 $9 、4 、4 、2 、1$。 Translated from [Alan_CRL](https://www.luogu.com.cn/user/349225)题目描述
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. 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. It is guaranteed that the construction always has walls on it's edges. The input will be correct. Your task is to print the size of the rooms from biggest to smallest.输入输出格式
输入格式
The first line has two numbers which are N and M, the size of the construction. Both are integers: $ n $ ( $ 1 \leq n \leq 10^3 $ ) $ m $ ( $ 1 \leq m \leq 10^3 $ ) Next N x M numbers represent each tile of construction.
输出格式
Once you finish processing the data your output consists of one line sorted from biggest to smallest room sizes.
输入输出样例
输入样例 #1
4 5
9 14 11 12 13
5 15 11 6 7
5 9 14 9 14
3 2 14 3 14
输出样例 #1
9 4 4 2 1