CF1699B.Almost Ternary Matrix
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two even integers n and m . Your task is to find any binary matrix a with n rows and m columns where every cell (i,j) has exactly two neighbours with a different value than ai,j .
Two cells in the matrix are considered neighbours if and only if they share a side. More formally, the neighbours of cell (x,y) are: (x−1,y) , (x,y+1) , (x+1,y) and (x,y−1) .
It can be proven that under the given constraints, an answer always exists.
输入格式
Each test contains multiple test cases. The first line of input contains a single integer t ( 1≤t≤100 ) — the number of test cases. The following lines contain the descriptions of the test cases.
The only line of each test case contains two even integers n and m ( 2≤n,m≤50 ) — the height and width of the binary matrix, respectively.
输出格式
For each test case, print n lines, each of which contains m numbers, equal to 0 or 1 — any binary matrix which satisfies the constraints described in the statement.
It can be proven that under the given constraints, an answer always exists.
输入输出样例
输入#1
3 2 4 2 2 4 4
输出#1
1 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1
说明/提示
White means 0 , black means 1 .
The binary matrix from the first test caseThe binary matrix from the second test caseThe binary matrix from the third test case