Crossword Puzzle Words
Time limit1sMemory limit1024 MB
Count the across and down words of length two or more in a crossword grid where '-' is an empty cell and '#' is a black square.
- Level
Easy2 of 10
- Topics
- Implementation, Matrix
- Solved
- No attempts yet
Describe the crossword grid
Consider a crossword puzzle grid, where '-' is an empty cell and '#' is a black square:
- - - - #
- - # # -
- - - - -
- # # - -
# - - - -
A word must be at least two characters long and contiguous, following the traditional crossword rules. In this example, there are five across words and four down words.
Read in a crossword puzzle and count the number of across words and down words.
Input
- Line 1: A single integer N, 3 ≤ N ≤ 100, the dimension of the square puzzle.
- Lines 2 to N+1: N characters each, either '-' or '#', representing the puzzle.
Output
Print a single line with two integers:
- the number of across words
- the number of down words