CF1699B.Almost Ternary Matrix

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two even integers nn and mm . Your task is to find any binary matrix aa with nn rows and mm columns where every cell (i,j)(i,j) has exactly two neighbours with a different value than ai,ja_{i,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)(x,y) are: (x1,y)(x-1,y) , (x,y+1)(x,y+1) , (x+1,y)(x+1,y) and (x,y1)(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 tt ( 1t1001 \le t \le 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 nn and mm ( 2n,m502 \le n,m \le 50 ) — the height and width of the binary matrix, respectively.

输出格式

For each test case, print nn lines, each of which contains mm numbers, equal to 00 or 11 — 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 00 , black means 11 .

The binary matrix from the first test caseThe binary matrix from the second test caseThe binary matrix from the third test case

首页