Pro.ID22168 TitleDigits Recognize System Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22168 AC4 Submit10 Ratio40.00% 时间&空间限制描述Given a n*m 01 array, consists by "0" and "1", which respect a picture, 0 for blank and 1 for colored. Please find out the digits (0-9) in the picture. Note: there may be many digits in one picture, please output the digits from left to right, and top to bottom (according to its left-up most point). You can find it in the Sample. All the digits appear in the picture are legality. Digits are represented in the form listed in Table 1. Table 1 Digit representation of 0-9 0 1 2 3 4 5 6 7 8 9 Digits will be appearing just like showing above, and they may be zoom in or zoom out. The nonstandard situation will not happen in the picture. The effect of "zoom in & zoom out" can make the lines of digits become longer synchronal, but not become shorter or wider. For example, the digit "4" can transform to: 1001 But it can not transform to: 1101 (the line become wider). And it can't transform to: 001 (the vertical lines of both sides don't be zoom out synchronal). The input ensure each two digits to be recognize will be separated by one line or one column "0" at least. The input ensure every digit to be recognize have legal shape, i.e. every "1" in the picture should be one part of the legal recognized digit. 输入There are multiple test cases. For each test case, there are two positive integers n and m ( n < 100, m < 100 ). Each of the following n lines contains m characters, this "01" matrix shows the picture to be recognized. Input terminated by "0 0". Assume every test case contains one digit to be recognized at least. 输出Description Given a n*m 01 array, consists by "0" and "1", which respect a picture, 0 for blank and 1 for colored. Please find out the digits (0-9) in the picture. Note: there may be many digits in one picture, please output the digits from left to right, and top to bottom (according to its left-up most point). You can find it in the Sample. All the digits appear in the picture are legality. Digits are represented in the form listed in Table 1. Table 1 Digit representation of 0-9 0 1 2 3 4 5 6 7 8 9 Digits will be appearing just like showing above, and they may be zoom in or zoom out. The nonstandard situation will not happen in the picture. The effect of "zoom in & zoom out" can make the lines of digits become longer synchronal, but not become shorter or wider. For example, the digit "4" can transform to: 1001 But it can not transform to: 1101 (the line become wider). And it can't transform to: 001 (the vertical lines of both sides don't be zoom out synchronal). The input ensure each two digits to be recognize will be separated by one line or one column "0" at least. The input ensure every digit to be recognize have legal shape, i.e. every "1" in the picture should be one part of the legal recognized digit. Input There are multiple test cases. For each test case, there are two positive integers n and m ( n < 100, m < 100 ). Each of the following n lines contains m characters, this "01" matrix shows the picture to be recognized. Input terminated by "0 0". Assume every test case contains one digit to be recognized at least. Output For each test case, output the digits that be recognized successfully on a single line, from left to right, and from top to bottom. Sample Input 5 3 Sample Output 9 Source 样例输入5 3 样例输出9 作者 |