시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 81 | 19 | 19 | 25.333% |
Nurikabe is a binary determination puzzle originating from Japan. Given a grid where some cells contain numbers, the objective of the puzzle is to mark each blank cell as either island (white) or water (black), while obeying the following constraints:
In this problem, you are asked to verify that Nurikabe puzzles are solved correctly.
The first line of input contains a single number T, the number of test cases that follow. The first line of each test case contains integers N and M, the size of a puzzle in rows and columns. The next N lines contain the rows of the puzzle. Each line contains characters from the set 123456789.#
where .
and any digit represent an island cell and #
represents a water cell.
For each test case, output YES if the board is filled in correctly according to the rules, and NO otherwise.
2 9 10 2.#...##.2 ###..#2### #2#.7#.#.# #.######.# ##.#..3#3# .#2####3## 2##4.#..#. ##..#####. #1###.2#4. 2 2 #1 1#
YES NO
Contest > IDI Open Contest > IDI Open 2010 F번