#C10212. Alternate Planting in a Grid
Alternate Planting in a Grid
Alternate Planting in a Grid
You are given a grid with dimensions \(n \times m\). The task is to fill the grid with two types of crops: 'C' and 'P'. The top-left cell (cell at position (0,0)) should always contain 'C'. Every adjacent cell (in both rows and columns) must alternate the crop type so that no two adjacent cells (horizontally or vertically) have the same crop.
The expected output is a grid pattern with the first line being "YES" if a grid can be constructed. Following that, there will be \(n\) lines each containing a string of length \(m\) representing the crop arrangement. Note that it is always possible to construct the grid with the given pattern.
The pattern follows the rule:
\[ \text{grid}[i][j] = \begin{cases} C, & \text{if } (i+j) \mod 2 = 0, \\ P, & \text{if } (i+j) \mod 2 = 1. \end{cases} \]inputFormat
The input consists of two space-separated integers \(n\) and \(m\) on a single line, representing the number of rows and columns of the grid respectively.
outputFormat
Output to standard output. If the grid can be constructed, the first line should be "YES" followed by \(n\) lines, each containing a sequence of exactly \(m\) characters according to the described alternating pattern. If for any reason the grid cannot be constructed (although under the problem constraints it always can), output "NO".
## sample2 2
YES
CP
PC
</p>