#C4615. Distinct Adjacent Grid Generation
Distinct Adjacent Grid Generation
Distinct Adjacent Grid Generation
You are given two positive integers \(m\) and \(n\) representing the number of rows and columns respectively. Your task is to generate a grid of size \(m \times n\) filled with non-negative integers such that any two adjacent cells (vertically or horizontally) have different values.
A simple way to achieve this is to fill the grid using an alternating pattern with the numbers 1 and 2. In other words, for each cell at position \((i, j)\), if \(i+j\) is even, the cell should contain 1; otherwise, it should contain 2. This ensures that no two adjacent cells have the same value.
Example:
Input: 3 3 Output: 1 2 1 2 1 2 1 2 1
inputFormat
The input consists of two space-separated integers \(m\) and \(n\) provided via standard input.
outputFormat
Output the generated grid with \(m\) rows. Each row should be printed on a new line with the \(n\) numbers separated by a single space.
## sample3 3
1 2 1
2 1 2
1 2 1
</p>