2018牛客多校训练----Another Distinct Values(数学规律)

这是一道来自牛客网的编程题目,挑战者需要填充一个n*n的矩阵,使得每行和每列的和都是独特的值,且限于-1, 0, 1。奇数长度的矩阵无法满足条件,而偶数长度的矩阵可以通过对角线划分进行构造,保证行列和的多样性。" 133155307,19991358,TiDB HTAP在新能源车企实时数据分析的应用,"['数据库', '数据分析', '实时处理', '新能源汽车', 'TiDB']
摘要由CSDN通过智能技术生成

链接:https://www.nowcoder.com/acm/contest/142/D
来源:牛客网
 

题目描述

Chiaki has an n x n matrix. She would like to fill each entry by -1, 0 or 1 such that r1,r2,...,rn,c1,c2, ..., cn are distinct values, where ri be the sum of the i-th row and ci be the sum of the i-th column.

输入描述:

There are multiple test cases. The first line of input contains an integer T (1 ≤ T ≤ 200), indicating the number of test cases. For each test case:
The first line contains an integer n (1 ≤ n ≤ 200) -- the dimension of the matrix.

输出描述:

For each test case, if no such matrix exists, output ``impossible'' in a single line. Otherwise, output ``possible'' in the first line. And each of the next n lines contains n integers, denoting the solution matrix. If th
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值