#C2412. Grid Acorn Checker
Grid Acorn Checker
Grid Acorn Checker
You are given a 2D grid consisting of rows of binary strings. Each cell in the grid is either '1' (representing an acorn) or '0' (empty).
Your task is to determine if every row and every column of the grid contains at least one acorn. In other words, every row and every column must have at least one occurrence of the character '1'. If this condition is satisfied, output Yes
; otherwise, output No
.
Note: The grid is described by two integers \( R \) and \( C \) (the number of rows and columns respectively), followed by \( R \) lines each containing a binary string of length \( C \). All indices are 0-based.
inputFormat
The first line of input contains two space-separated integers \( R \) and \( C \), representing the number of rows and columns of the grid, respectively.
Each of the next \( R \) lines contains a binary string of length \( C \) composed only of characters '0' and '1'.
outputFormat
Output a single line containing either Yes
if every row and every column of the grid contains at least one '1', or No
otherwise.
4 4
1011
0110
1100
1011
Yes
</p>