#K95507. Fully Occupied Grid Check
Fully Occupied Grid Check
Fully Occupied Grid Check
You are given a 3x3 grid where each cell is either an 'X' or a '.'. The grid is represented by three lines of input, each containing exactly three characters. Your task is to determine if there exists at least one row or at least one column that is entirely occupied by the character 'X'.
If such a row or column exists, print YES
; otherwise, print NO
.
Formally, let \(G\) be a \(3 \times 3\) matrix where \(G_{ij}\) is either 'X'
or '.'
. You need to check if there exists an \(i\) with \(1 \le i \le 3\) such that \(G_{i1} = G_{i2} = G_{i3} = 'X'\), or there exists a \(j\) with \(1 \le j \le 3\) such that \(G_{1j} = G_{2j} = G_{3j} = 'X'\).
inputFormat
The input consists of exactly three lines. Each line contains exactly three characters (either 'X'
or '.'
) without spaces.
outputFormat
Output a single line: YES
if there exists a fully occupied row or column by 'X', and NO
otherwise.
X.X
XXX
.X.
YES