F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

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
3 2 2 1 3 2 4 2 3 1 1 1 1 1 1 2 1 2 3
 

Sample Output
YES YES NO
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 00:31:17, Gzip enabled