CT073

Crossword Grid Validator

HardAcceptance: 0.0%

A valid American-style crossword grid is an n x n matrix of black (1) and white (0) squares satisfying: every white square is part of two words (across and down), all words are at least 3 letters, the grid is rotationally symmetric, and all white squares are connected. Given a grid, determine if it is valid. Input: first line n, then n lines each with n values (0 or 1). Output "true" or "false".

Example 1:

Input: 5 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0
Output: false

Example 2:

Input: 5 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
Output: true

Constraints:

1 <= n <= 100 Grid values are 0 (white) or 1 (black)

Tags:

matrix validation bfs simulation
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki