|
||||||||||
DifferenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1053 Accepted Submission(s): 317 Problem Description A graph is a difference if every vertex vi can be assigned a real number ai and there exists a positive real number T such that (a) |ai| < T for all i and (b) (vi, vj) in E <=> |ai - aj| >= T, where E is the set of the edges. Now given a graph, please recognize it whether it is a difference. Input The first line of input contains one integer TC(1<=TC<=25), the number of test cases. Then TC test cases follow. For each test case, the first line contains one integer N(1<=N<=300), the number of vertexes in the graph. Then N lines follow, each of the N line contains a string of length N. The j-th character in the i-th line is "1" if (vi, vj) in E, and it is "0" otherwise. The i-th character in the i-th line will be always "0". It is guaranteed that the j-th character in the i-th line will be the same as the i-th character in the j-th line. Output For each test case, output a string in one line. Output "Yes" if the graph is a difference, and "No" if it is not a difference. Sample Input
Sample Output
Hint In sample 1, it can let T=3 and a1=-2, a2=-1, a3=1, a4=2. Source | ||||||||||
|