![]() |
||||||||||
|
||||||||||
Is it a fantastic matrix?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1 Accepted Submission(s): 1 Problem Description Given an n*m matrix, you are asked to judge if it's fantastic. The rule is: firstly, choose min (n, m) numbers from it, meanwhile you should make sure any two numbers you select will not at the same row or same column. Of course, you may have many different ways to get the numbers. For every way, if the sum of all selected numbers is always same, you may say the matrix is fantastic. Input The first line contains an integer T, stands for the number of test cases. (1<=T<=100) T cases follow, for every case: The first line contains two integers n and m. (1 <= n, m <= 50) Then n lines follows, each line contains m integers. Every number in the matrix will between -100000 and 100000. Output For every case, if it is a fantastic matrix, output “YES” in one line, otherwise output “NO”. Sample Input
Sample Output
Source | ||||||||||
|