#P3164. [CQOI2014] 和谐矩阵

    ID: 2213 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2014重庆各省省选Special Judge高斯消元异或方程组

[CQOI2014] 和谐矩阵

Description

We call a matrix composed of 00 and 11 harmonious if and only if every element has an even number of adjacent 11's. The neighbors of an element include the element itself and its four neighbors above, below, left, and right (if they exist). Given the number of rows and columns of the matrix, compute and output a harmonious matrix. Note: the all-zero matrix is not allowed.

Input Format

The input consists of one line containing two space-separated integers mm and nn, denoting the number of rows and columns of the matrix.

Output Format

Output mm lines, each containing nn space-separated integers (00 or 11), forming the required matrix. The testdata guarantees that a solution exists.

4 4
0 1 0 0
1 1 1 0
0 0 0 1
1 1 0 1


Hint

Constraints

1n,m401\le n,m\le 40.

Thanks to @miaomiao for providing the SPJ.

Translated by ChatGPT 5